Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-14-2011, 12:38 PM   PM User | #1
Arjun21
New to the CF scene

 
Join Date: Nov 2011
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Arjun21 is an unknown quantity at this point
Prepared statement problem

Well, i have a problem in prepared statement with 'bind_param'

My queries looks like this

PHP Code:
<?php
$result 
$db_connection->prepare("update users set date = ? where email= ?");
    
$result->bind_param("s"$mysqlDateString));
    
$result->bind_param("s"$email);
    
$result->execute();

?>
Here $mysqlDateString is the date variable
When i execute this, it gives error

Quote:
Fatal error: Call to a member function bind_param() on a non-object in F:\xampp\htdocs\Login.php on line 21
Here what should be the variable type of date. I have tried many things but nothing works.
Arjun21 is offline   Reply With Quote
Old 12-14-2011, 04:37 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Given the error you are missing a lot of code here.
This isn't the right way to use bind_param though. That should be $result->bind_param("ss", $mysqlDateString, $email);. If $result is not an object as its complaining about here, this indicates that the prepare has failed. $db_connection appears to me to be a MySQLi object, otherwise the prepare would have fatal error on it as well.
You can try adding an error in there.
PHP Code:
if ($result $db_connection->prepare('...'))
{
    
// ...
}
else
{
    
printf('Error: %s'$db_connection->error);

Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
date, prepare

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:28 AM.


Advertisement
Log in to turn off these ads.