Re: strange problem of mysql_query

From: Date: Wed, 02 Jun 2010 09:43:37 +0000
Subject: Re: strange problem of mysql_query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-305739@lists.php.net to get a copy of this message
On Wed, 2010-06-02 at 17:36 +0800, I am on the top of the world! Borlange University wrote: > hey, i have a sql string like below: > select szs_content from szs_gy_ca where szs_shengchanhao='09-s525' and > szs_guige='48B32/14-1 1/8"' and szs_tuhao='48B32 1 1/8' > > the problem is that using mysql_query to run this sql string returns > nothing,however, i can get one record through mysql query tool. > > i was wondering whether the double quote 48B32/14-1 1/8" makes this trouble. The double quotes inside of that query won't cause any trouble, but you haven't shown us how you're executing the query with PHP. The usual is to do something like this: $query = "select szs_content from szs_gy_ca where szs_shengchanhao='09-s525' and szs_guige='48B32/14-1 1/8\"' and szs_tuhao='48B32 1 1/8'"; $result = mysql_query($query); Note that the double quote there is escaped because you're already using double quotes as the string identifier in PHP. If that still doesn't give you the results you expect, it's more likely a logic problem than a syntax issue. Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#305739) next »