Jump to content
Larry Ullman's Book Forums

Insert Into Mysql


Recommended Posts

Used your Script 12.4 on page 362 as an example to test my code at my Web host.  Kept getting an SQL error of invalid syntax.  Did some research on the Internet and someone's reply had an answer.  I'm using the object oriented approach as opposed to the procedural.  So the executable part would be:

 

$db = new mysqli (etc.);

if($db->query($sql) === TRUE {etc.

 

The last part of the $sql statement in your script would then be:

 

etc. VALUES (0, '" .$title. "', '" .$entry. "'," NOW())";

 

The PHP engine on my site doesn't like the syntax of a straightforward statement, so you have to separate the variables and include single quotes within quotes so that the variables will be properly surrounded with quotes.

 

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...