![]() |
|
|
|
|
1
2nd November 10:18
External User
Posts: 1
|
Hi everyone.
I have a script that I've been using succesfully for quite awhile, and just today found a bug... I attempted to insert a new record into the database and got this error in my error log: [Fri Dec 21 11:08:43 2007] [error] PHP Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in /Volumes/RAIDer/webserver/Documents/OLDB/add.php on line 31 [Fri Dec 21 11:08:43 2007] [error] PHP Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in /Volumes/ RAIDer/webserver/Documents/OLDB/add.php on line 33 [Fri Dec 21 11:08:43 2007] [error] PHP Warning: mysqli_stmt_affected_rows() expects parameter 1 to be mysqli_stmt, boolean given in /Volumes/RAIDer/webserver/Documents/OLDB/add.php on line 35 [Fri Dec 21 11:08:43 2007] [error] PHP Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt, boolean given in /Volumes/ RAIDer/webserver/Documents/OLDB/add.php on line 41 And those lines from my script are: //Create the statement $stmt = mysqli_prepare($link, "INSERT INTO current VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); mysqli_stmt_bind_param($stmt, 'sssssssss', $FName, $LName, $Add1, $Add2, $City, $State, $Zip, $XCode, $Record); //Add the record mysqli_stmt_execute($stmt); printf("%d Row Inserted.\n", mysqli_stmt_affected_rows($stmt)); // Redirect back to index.php for viewing //header("Location: index.php"); //Close the statement mysqli_stmt_close($stmt); ?> The $stmt is line 30 only thing above it is mapping the post info to the field names to be inserted. With my limited knowledge of mysqli functions, it could be the issue... But what I don't get is why this bug is rearring it's head now... When I'm supposed to go on vacation for a few weeks... Any help would be greatly appreciated. The basics of what I used was copied directly from the php.net site. so I'm very confused... -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com japruim@raoset.com |
|
|
|
|
3
2nd November 10:19
External User
Posts: 1
|
Here is where I connect to the database:
<?php $link = mysqli_connect($server, $username, $password, $database) ; /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ?> It looks valid to me... as long as it's connecting... the username/ password/database are all correct, I can log in from the command line with no issue.... -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com japruim@raoset.com |
|
|
5
2nd November 10:19
External User
Posts: 1
|
Hey Zoltan,
Thanks for looking, here's the result of the vardump, I did $link first and then $stmt object(mysqli)#1 (0) { } bool(false) Not quite what it should be is it? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com japruim@raoset.com |
|
|
9
4th November 10:03
External User
Posts: 1
|
Perhaps it is valid, when the database is up and running.
But if your DB was re-started for some reason, the link won't be there while it's restarting will it? You've GOT to write code to handle the $link being false instead of marching blindly off the cliff. You are not a lemming. :-) -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? |
|