Re: Single/Double Quotes

From: Date: Wed, 12 Dec 2001 19:41:06 +0000
Subject: Re: Single/Double Quotes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77478@lists.php.net to get a copy of this message
I see your question has already been answered, but I'll add a tip that works well for me. Whenever I want to perform an SQL query that involves PHP variables I will write the query string to its own variable instead of directly into the function. Then use that variable in the query function... $query = "SELECT * FROM my_table WHERE column1 = '$mydata' && column2 = '$mydata2' ORDER BY $order_col $asc_desc"; $result = mysql_query("$query", $db); -Kevin ----- Original Message ----- From: "Gerard Samuel" <trini0@optonline.net> To: "PHP" <php-general@lists.php.net> Sent: Wednesday, December 12, 2001 7:08 AM Subject: [PHP] Single/Double Quotes > Im tring to rewrite some code to use single/double quotes correctly (as > correct as can be). > > If I use > $result=mysql_query('SELECT book FROM ' . TAB_AUTHORS . " WHERE aid = > $aid"); > I get an mysql error. That should be correct, if I understand it right. > > But if I use > $result=mysql_query('SELECT book FROM ' . TAB_AUTHORS . " WHERE aid = > '$aid'"); > it works. > > > So what I need to know is that do I have to ride the fine thin line for > correctness and speed??? > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#77478) next »