Jump to content

[SOLVED] stmt_init(), prepare(), bind_parameter() not working...


ShootingBlanks

Recommended Posts

Hello - here is some code.  I'll explain below what's not working:

$conn = new mysqli([i]hostname[/i], [i]username[/i], [i]password[/i], [i]database[/i]) or die('Cannot open database');

$stmt = $conn->stmt_init();

if (isset($_POST['users'])) {
	$getDocId = "SELECT doc_id FROM documents
				 WHERE title_full = ? AND title_short = ? AND what_is = ?
				 AND why_use = ? AND not_followed = ? AND doc_content = ? AND live_doc = ?";
	// statement object already exists, so you just need to prepare it with the new SQL
        if ($stmt->prepare($getDocId)) {
          // bind parameters and execute statment
          $stmt->bind_param('sssssss', $title_full, $title_short, $what_is,
	  					 $why_use, $not_followed, $doc_content, $live_doc);
      // bind the result to $image_id
      $stmt->bind_result($doc_id);
	      // execute the statement and get the result
      $OK = $stmt->execute();
      $stmt->fetch();
      // free the statment for the next query
      $stmt->free_result();
    }
}

 

The problem is that it works on the local PHP/MySQL setup that I have on my computer, but it doesn't work when uploaded to my server.  Is it possible that it has to do with varying versions of PHP/MySQL on my server versus what's on my local machine?  If so, is there a more "universal" way to accomplish what I am trying to do above, so that it works on my server as well?  Thanks!...

 

if you recently installed php on your system, then you most likely installed version 5, and many hosts are still running version 4. You can verify this by adding the following to your script, or a blank php file, uploading it to your server, and then viewing it in your browser:

 

phpinfo();

 

If your host isn't running php5... I'd look for another host. php5 makes a lot of scripting WAY easier.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.