close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

debugging mysqli insert query

Thread began 7/15/2019 2:58 am by CraigR | Last modified 7/19/2019 8:44 am by Ray Borduin | 45 views | 6 replies |

CraigRBeta Tester

debugging mysqli insert query

i have a site which has been working fine until recently, but some errors are coming to light after the host updated to a newer version of mySQL

one issue I have encountered is an insert query, which populates a table if certain criteria are met, however I am unable to check the insert statement.

here is my code

php:
<?php

if (isset($_POST["Create"]) && isset($campaignid)) {
    
    
$new_invitees array_diff($_SESSION['memberidsinmailing'],$already_invited); 
    
//compare the 2 arrays, and return the member id's who are in the campaign send list, but have not already received an invitation
    //the members already sent will get another email, but they will not get a new entry in the tbleventmember table

    
foreach ($new_invitees as $invitedmember) {
      
$InsertQuery = new WA_MySQLi_Query($PowerCMSConnection_i);
      
$InsertQuery->Action "insert";
      
$InsertQuery->Table "tbleventmember";
      
$InsertQuery->bindColumn("EventID""i""".isset($_GET['EventID'])?$_GET['EventID']:''."""WA_DEFAULT");
      
$InsertQuery->bindColumn("MemberID""i""".$invitedmember."""WA_DEFAULT");
      
$InsertQuery->bindColumn("InviteSent""i""0""WA_DEFAULT");
      
$InsertQuery->bindColumn("CampaignID""s""".$campaignid."""WA_DEFAULT");
      
$InsertQuery->saveInSession("eventmember");
      
$InsertQuery->execute();
      
$InsertGoTo "";
      if (
function_exists("rel2abs")) $InsertGoTo $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
      
$InsertQuery->redirect($InsertGoTo);
    }
}
?>



in order to try and debug, i added some statement on $_POST["Create"]

php:
echo $InsertQuery->debugSQL();



but the page returns an error

Fatal error: Call to a member function debugSQL() on null

if i run the debugSQL() function on a recordset from a SELECT statement with a which is also on the page, i get the expected output.

I have set $this->Debug = true; in both rsobj.php (version 2.18) and queryobj.php (version 1.5)

Sign in to reply to this post

Ray BorduinWebAssist

This means that there were no inserts performed. Most likely your logic for returning the array of new invitees is returning no results.

Try doing:

php:
<?php

var_dump
($new_invitees);
if (
sizeof($new_invitees) > 0) {
  echo 
$InsertQuery->debugSQL();
}
?>
Sign in to reply to this post

CraigRBeta Tester

i tried simply using a variable in a block of code on a new page as follows...

php:
<?php require_once('Connections/PowerCMSConnection_i.php'); ?>

<?php 
require_once('webassist/mysqli/rsobj.php'); ?>
<?php 
require_once('webassist/mysqli/queryobj.php'); ?>
<?php
if ("" == "") {


      
$InsertQuery = new WA_MySQLi_Query($PowerCMSConnection_i);
      
$InsertQuery->Action "insert";
      
$InsertQuery->Table "tbleventmember";
      
$InsertQuery->bindColumn("EventID""i""275""WA_DEFAULT");
      
$InsertQuery->bindColumn("MemberID""i""101""WA_DEFAULT");
      
$InsertQuery->bindColumn("InviteSent""i""0""WA_DEFAULT");
      
$InsertQuery->bindColumn("CampaignID""s""".$campaignid."""WA_DEFAULT");
      
$InsertQuery->saveInSession("eventmember");
      
$InsertQuery->execute();
      
$InsertGoTo "";
      if (
function_exists("rel2abs")) $InsertGoTo $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
      
$InsertQuery->redirect($InsertGoTo);
          
}

           echo 
$InsertQuery->debugSQL();

?>



but this gives me the following...


Fatal error: Call to undefined method WA_MySQLi_Query::debugSQL() in D:\vhosts\inchorus\_sqldump_test.php on line 23

(though the query runs ok and the table is updated)

Sign in to reply to this post

Ray BorduinWebAssist

What version of queryobj.php are you using? That feature wasn't in earlier versions, but it should work in the current one if you reinstall.

Sign in to reply to this post

CraigRBeta Tester

Hi Ray, it’s version 1.5,is there a newer one ?

Sign in to reply to this post

Ray BorduinWebAssist

Yes, I have version 2.2... I'll attach it.

Attached Files
queryobj.php
Sign in to reply to this post

CraigRBeta Tester

PERFECT !

Thanks again.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...