Re: Concatenating fields
| From: | Richard S. Crawford | Date: | Wed, 24 Oct 2001 17:18:12 +0000 |
| Subject: | Re: Concatenating fields | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13679@lists.php.net to get a copy of this message | ||
Try escaping the quotes:
$ssql="select concat(category, \"-\", code) as ..."
Either that, or try surrounding the - with single quotes, as in '-'.
What's probably happening is that the query is being rendered as "select concat (category, ", which isn't a valid query.
At 10:15 AM 10/24/2001, you wrote:
I am using concat in my sql and it runs fine on mysql client. But when used in php it gives me an error: Supplied argument is not a valid MySQL result resource in <b>/var/www/html/scripts/cfg_code_delete.php</b> on line < $ssql="select concat(category, "-", code) as fill_column, code_id as submit_column from sys_code_tbl order by category"; echo "<OPTION selected value=\"\"></OPTION>"; $result = mysql_query($ssql); while ($row = mysql_fetch_array($result)) {Sliante, Richard S. Crawford http://www.mossroot.com mailto:rscrawford@mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!"echo "<OPTIONvalue='".$row["submit_column"]."'>'".$row["fill_column"]."'</OPTION>"; } Help is appreciated. Regards, Harpreet Kaur Software Developer Crispin Corporations Inc. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net