Variable in the statement

From: Date: Tue, 22 May 2001 07:54:25 +0000
Subject: Variable in the statement
Groups: php.windows 
Request: Send a blank email to php-windows+get-7802@lists.php.net to get a copy of this message
Hi, I've got a problem with variables. I am trying to make a select staement for mysql using a variable in the where clause. If i don't use the variable the result comes out fine but with it there are parser errors on other lines. Can anybody tell me how to insert a variable in such a script. <html> <body> <?php global $titel; $titel='html' $db = mysql_connect("localhost", "root") or die ("Kan geen connectie maken met het database programma. De Database server kan uit staan.");; mysql_select_db("setf",$db) or die ("Kan geen connectie maken met de database"); $result = mysql_query("SELECT titel FROM onderwerpen where titel=$titel") or die ("kan niks uit de database lezen. Reload en probeer het nog een keer."); // the other select i used: $result = mysql_query("SELECT titel FROM onderwerpen where titel='$titel'") //The working select without a variable $result = mysql_query("SELECT titel FROM onderwerpen where titel='html'") printf("titel: %s<br>\n", mysql_result($result,0,"titel")); ?> </body> </html> If anybody can help me Thanx in advance Pepijn

« previous php.windows (#7802) next »