Fatal error: Call to a member function query() on a non-object

Tengo el siguiente problema en mi código.Fatal error

Mi código es el siguiente:

 <?php  $  cor=$  _REQUEST['cor']; $  pas=$  _REQUEST['pas'];   $  cnx=mysql_connect('','root',"") or die('No se puede conectar a la BD');  mysql_select_db('proyecto_tienda1',$  cnx) or die('No se puede seleccionar la BD');  $  res=$  cnx->query("select * from usuarios where correo='$  cor' and pas='$  pas'") or die($  cnx->error);  $  datos=array(); foreach($  res as $  row){     $  datos[]=$  row; } echo json_encode($  datos); ?> 

El error se encuentra en la siguiente linea:

$  res=$  cnx->query("select * from usuarios where correo='$  cor' and pas='$  pas'") or die($  cnx->error); 

Cabe recalcar que anteriormente me daba el siguiente error error 2

pero al quitar localhost y agregar la ip local ya no me daba el fatal error. Esta era como lo manejaba anteriormente

$  cnx=mysql_connect('localhost','root',"") or die('No se puede conectar a la BD'); 


How to add AJAX call back from another AJAX result in a form

I want to use 2 AJAX call back within a form. The scenario is like I am having a text field and a Search button which is defined in the form alter function. After entering a text and clicking on the Search button, will display some matching strings with some other information from database as an HTML in ul li a format.

I had made each string as a form element link and displaying under the search field. Now, I need to add AJAX callback to this link and after clicking on any string, the whole HTML content has to be removed and some other new text fields should be displayed in the form and the selected string should be placed on the text field.

Please see below codes.


  $  form['searchbutton'] = array(       '#type' => 'button',       '#value'=> t('Search'),       '#id'   => 'search_button',       '#ajax' =>  array(           'callback' => 'ajax_search_callback',           'wrapper' => 'search-list-wrapper',           'method' => 'replace',           'effect' => 'fade',           'progress' => array('type' => 'none'),         )      ); 

Below code is the first AJAX call on button click

/**      * AJAX call back       */ function ajax_search_callback($  form, $  form_state) {  //getting matching list from database with respect to search text // $  search_results   $  form['link-lists'] = array(         '#type' => 'item',                       '#prefix' => "<ul>",         '#suffix' => "</ul>",     );  foreach ($  search_results as $  key => $  result) {         $  result_html = "<p class=\"matching-title\">" . $  result['title'] . "</p>                 <p class=\"matching-desc\">" . $  result['description'] . "</p>";          $  form['link-lists']['options'.$  key] = array(             '#type' => 'link',             '#prefix' => "<li class=\"matching-list-item\">",             '#suffix' => "</li>",             '#title' => $  result_html,             '#href' => '#',             '#options' => array(               'html' => true,             ),             '#ajax' => array(               'wrapper' => 'search-list',               //'method' => 'html',               'callback' => 'select_ajax_callback',             )       );    }   $  commands = array();   $  commands[] = ajax_command_replace('#descriptions-list', drupal_render($  form['link-lists']));   $  page = array('#type' => 'ajax', '#commands' => $  commands);   return $  page;   } 

I think, the second AJAX call back select_ajax_callback given for the form item link is not correct. It would be thankful if anyone can help me on below questions?

  1. How to set callback for a form item link? Please correct me.
  2. How I will get $ form and $ form_state values in the function select_ajax_callback. And in this function I need to return another form element which is already defined in the form alter.

Thank You.

Magento 2.2 – Fatal error: Uncaught Error: Call to undefined method Magento\Framework\App\ResourceConnection::load()

Fatal error: Uncaught Error: Call to undefined method Magento\Framework\App\ResourceConnection::load() in /var/www/html/magento2_dev/vendor/magento/framework/Model/AbstractModel.php:536

Just adding the resource connection on my extended Sales Model, getting the above issue.

Below is my code:

<?php namespace Sdi\Sales\Model; use Magento\Framework\App\Request\DataPersistorInterface; class Order extends \Magento\Sales\Model\Order {    protected $  _resource;    public function __construct(         \Magento\Framework\App\ResourceConnection $  resource ) {     $  this->_resource = $  resource; } public function bnDelete() {     if ($  this->getStatus() == Mage_Sales_Model_Order::STATE_CANCELED) {         $  connection = $  this->_resource->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);         $  query = 'SQL QUERY';         $  connection->query($  query);     }     return false; } } 

SharePoint 2013 Designer workflow – Second identical REST call returns XML and thus errors out. Why is this?

I have a workflow defined on the Workflow Tasks list and I have a simple REST call to that same list and then I repeat the exact same REST call to that list and the first one works like a charm, the second one does not. It Hangs and the error seems to imply the results are coming back via XML and not JSON. Though the Dictionary, I’ve defined have the following structure,

Accept String application/json;odata=verbose

Content-Type String application/json;odata=verbose

My original code actually had the second REST Call to a different List, but to debug, simplify, I used an exact copy. I even put it into a different Stage to see if that made a difference. I even used the exact same variables for the Call and tried using completely different variables.

What is going on here? Why is the second call which now is exactly coded as the first call returning as XML. The message I get while it is hung up is:

RequestorId: 65d32ce8-525e-74ba-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.IO.InvalidDataException: Unable to deserialize HTTP response content. Expected ContentType : ‘application/json’, ‘text/plain’ or ‘text/html’, Received ContentType : ‘application/atom+xml’. Content (truncated) : ‘fd1431e7-4227-46b2-afcf-2f025ef99f7a2019-05-21T16:07:30Z’. ResponseStatusCode : ‘OK’ Request Uri : ‘https://xxx/hc/teams/MES//_api/lists/GetByTitle(‘Workflow Tasks’)/Items?$ select=Title&$ filter=(Project_x0020_ID eq ‘Sample1 23’) and (TaskUID eq ‘0’) and (PercentComplete ne 1)’ at Microsoft.Activities.Messaging.SendHttpRequest.OnReceiveResponse(NativeActivityContext context, Bookmark bookmark, Object value) at System.Activities.Runtime.BookmarkWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Thank you

PWA Workflow gets Access Denied for API Call to get Assignments

I have a SPD 2013 Workflow on our PWA site that has been working fine for 6 months. My colleague has left the business and Admin have disabled his 365 account.

Suddenly, the Workflow is failing and not pulling the correct info through.

I added email commands to the workflow to send me the contents of the dictionary variable straight after the API call for assignments and get the following:

{“error”:{“code”:”-2147024891, Microsoft.Office.Project.Server.Exceptions.ProjectServerUnauthorizedAccessException”,”message”:{“lang”:”en-US”,”value”:”Access denied. You do not have permission to perform this action or access this resource.”}}}

The Workflow/Email is shown below:

enter image description here

Email command

I have made sure I am a site owner, I have re-enabled my colleagues account as it was before he left, but it still fails.

The list workflow is triggering as me as the initiator now, where before it was my colleague.

I am not an expert on API/Workflows and cant figure out what im missing, currently this is affecting us being able to import project tasks to our SharePoint lists to schedule engineers.

Any Ideas what I need to do to get this working again would be extremely appreciated.

Many Thanks Dean