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!...

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.