Re: insert in mysql

From: Date: Fri, 26 Jan 2001 15:24:35 +0000
Subject: Re: insert in mysql
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6205@lists.php.net to get a copy of this message
> > if(! mysql_query('$sql')) > Why the single quotes around $sql. It's a string so you shouldn't have to > quote it at all. It's likely the single quotes that's causing the problems now. Like perl, single quotes in PHP are for 'absolute' strings, double quotes for 'interpreted' strings (strings that contain variable references, special characters like \n etc). By using single quotes you are passing the string '$sql' to the function. Use double quotes, or better yet (as Paul suggested) remove the quotes altogether to pass the _value of the $sql variable_ (i.e. your SQL query) to the mysql_query function. The rest looks good; except the lack of line breaks and indenting in your code, but I tend to be anal about that sort of thing :) - Darryl ---------------------------------------------------------------------- Darryl Friesen, B.Sc., Programmer/Analyst Darryl.Friesen@usask.ca Education & Research Technology Services, http://gollum.usask.ca/ Department of Computing Services, University of Saskatchewan ---------------------------------------------------------------------- "Go not to the Elves for counsel, for they will say both no and yes"

« previous php.db (#6205) next »