note 33126 added to function.mysql-query

From: Date: Tue, 17 Jun 2003 12:52:24 +0000
Subject: note 33126 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-50485@lists.php.net to get a copy of this message
There was one thing that caused me a lot of trouble as I was trying to launch an "INSERT INTO (...) VALUES(...)" query with mysql_query() command. The variables passed to the *.php file by <form method="get" action="..."> should be put between quotes (') in the VALUES clause. For example, it should be: $query = "INSERT INTO table (field) VALUES('$variable')"; and NOT $query = "INSERT INTO table (field) VALUES($variable)"; It took me a whole day to debug. It doesn't even send any error messages. The only clue I had was a "Query failed" message in response to: mysql_query($query) or die("Query failed") I hope this'll be of help to someone ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33126 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33126&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33126&report=yes

« previous php.notes (#50485) next »