simple INSERT statement with placeholders failing. I don"t understand why.
am 14.07.2009 01:58:39 von Govinda
this:
$q=mysqli_query($db_billing,'INSERT INTO billing (clientFname,
clientLname) VALUES (?,?)', array($defaultsFormVars[clientFname],
$defaultsFormVars[clientLname]));
is giving
Warning: mysqli::query() expects parameter 2 to be long, array given
in /home/meee/public_html/somedir/test.php on line 71
a "long"?! We need values for 2 text/BLOB columns.. an array seems
appropriate to me. It was with PEAR DB. WHy is it asking for a long?
it was working fine with PEAR DB before I turned that off to try and
learn better what was under PEAR.
I found
http://dev.mysql.com/doc/refman/5.1/en/insert.html
but there is no example of using placeholders there, so I can't
determine how to alter this example (which I learned from a book that
just breezes through with only the one quick PEAR DB example.)
If someone can even just point me to the right docs for this, I'd be
grateful.
thanks!
-G
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: simple INSERT statement with placeholders failing. I don"t understand why.
am 14.07.2009 05:31:08 von Niel Archer
> this:
>
> $q=mysqli_query($db_billing,'INSERT INTO billing (clientFname,
> clientLname) VALUES (?,?)', array($defaultsFormVars[clientFname],
> $defaultsFormVars[clientLname]));
>
> is giving
> Warning: mysqli::query() expects parameter 2 to be long, array given
> in /home/meee/public_html/somedir/test.php on line 71
>
> a "long"?! We need values for 2 text/BLOB columns.. an array seems
> appropriate to me. It was with PEAR DB. WHy is it asking for a long?
>
> it was working fine with PEAR DB before I turned that off to try and
> learn better what was under PEAR.
> I found
> http://dev.mysql.com/doc/refman/5.1/en/insert.html
> but there is no example of using placeholders there, so I can't
> determine how to alter this example (which I learned from a book that
> just breezes through with only the one quick PEAR DB example.)
>
> If someone can even just point me to the right docs for this, I'd be
> grateful.
> thanks!
http://uk.php.net/manual/en/mysqli.query.php
(Almost) all php functions are documented on the web site. So it would
be the best place to start looking.
You are mixing up several different methodologies in the example you
show.
More generally for MySQLi start here:
http://uk.php.net/manual/en/book.mysqli.php
It has links to the appropriate function references for the MySQL
Improved interface.
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Niel Archer
niel.archer (at) blueyonder.co.uk
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php