ShootingBlanks Posted September 28, 2007 Share Posted September 28, 2007 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!... Quote Link to comment https://forums.phpfreaks.com/topic/71086-solved-stmt_init-prepare-bind_parameter-not-working/ Share on other sites More sharing options...
sKunKbad Posted September 28, 2007 Share Posted September 28, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/71086-solved-stmt_init-prepare-bind_parameter-not-working/#findComment-357484 Share on other sites More sharing options...
ShootingBlanks Posted September 28, 2007 Author Share Posted September 28, 2007 On my server it says I have PHP 5, but MySQL/mysqli 4... On my local computer, both PHP and MySQL are at 5. So, yeah - that's probably the issue. Thanks!... Quote Link to comment https://forums.phpfreaks.com/topic/71086-solved-stmt_init-prepare-bind_parameter-not-working/#findComment-357503 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.