Re: mysqli_stmt_bind_param question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

First of all you must connect to the server and then perform an init to get a statement. Maybe you dropped that code out here... Please have a look at the manual page:

http://www.php.net/manual/en/function.mysqli-stmt-prepare.php

In order to get the result you also need to bind the result to a variable and then fetch the data.

I'll guess that your error comes from an unsuccessful initialization of your prepared statement.

If you don't want to include your primary key column that is autogenerated you just ignore it. That means to write a proper query like:

INSERT INTO legioCurrent (column_1, column_2, ...)
VALUES (?,?,...)

I would also like to propose for you to use the object oriented style, since it's more readable and easier to get an overview of. You also don't need to mess around with so many parameters.

Greetings,
Krister Karlström, Helsinki, Finland

Jason Pruim wrote:

Hi Everyone,

I have a MySQL database that I am accessing from PHP. The table in question has a auto increment field on it and I don't want to include that in my add/edit/update query's to the database... But I can't seem to figure out how to ignore it? Everything I have done seems to fail.. I am using prepared statements so I"m not sure it that is it, but I would like to keep using them since it reduces the security issues a little... Here is the code from one of my prepared statements:

//Create the statement
mysqli_stmt_prepare($stmt, "INSERT INTO legionCurrent VALUES ( ?,?,?,?,?,?,?,?)"); mysqli_stmt_bind_param($stmt, 'ssssssss', $FName, $LName, $Add1, $Add2, $City, $State, $Zip, $XCode)or die(mysqli_error($addlink));
//Add the record
mysqli_stmt_execute($stmt) or die(mysqli_error($addlink));

Here is the error I get in my logs:

[Fri Apr 4 09:35:32 2008] [error] PHP Warning: mysqli_stmt_bind_param() [<a href='function.mysqli-stmt-bind-param'>function.mysqli-stmt-bind-param</a>]: invalid object or resource mysqli_stmt\n in /Volumes/RAIDer/webserver/Documents/dev/OLDBv2/add.php on line 91

Line 91 is the mysqli_stmt_bind_param() line above

My database structure looks like this:

| FName | LName | Add1 | Add2 | City | State | Zip | XCode | Reason | Record

I know there is away to do it, but all my searching and reading hasn't told me anything... I've looked in the php manual, and mysql, plus various websites... and I just can't figure this one out... RTFM's are appreciated, as long as M is defined! :)

Thanks for taking the time to look!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@xxxxxxxxxx

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux