Forum Moderators: coopster
$title=mysql_real_escape_string($title);
$commentary=mysql_real_escape_string($commentary);
$condo="insert into books(title,topic_id,description)values('$title',$ topic,$commentary)";
$meen=mysql_query($condo) or die('defenestration error, open a new window<br />'.mysql_error());
As far as I can tell, the code should produce pretty much the same material for both $commentary and $title, a sanitized string. But when I run the code, I get this as the insert string, followed by the error.
insert into books(title,topic_id,description)values('Begining Ruby, from N#*$!x to P#*$!xx',7,Basic Ruby programming information)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Ruby programming information)' at line 1
It looks like $title is getting quote marks for some reason, but $commentary is not. Why is that?
Thanks for any assistance
NB, I munged the title for here just in case it caused TOS problems
Glad you got everything sorted yourself, though. :)
var $select = "select field from table where field='$myvariable'"; will interpolate because the PHP quote is double, the single quote is just a character within the string like $test = "this 'is' my $test"; But the single quote is one of the ways to correctly quote for a mysql statement, which is a different issue.
You'll get unecapsed T_STRING errors if you do
var $select = "select field from table where field='$row[0]'";
Which can be managed by
$var $myvariable = $row[0];
var $select = "select field from table where field='$myvariable'";
Or concatenate
var $select = "select field from table where field='".$row[0]."'";