[PHP] strange problem of mysql_query

2010-06-02 Thread I am on the top of the world! Borlange University
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.


Re: [PHP] strange problem of mysql_query

2010-06-02 Thread Ashley Sheridan
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




Re: [PHP] strange problem of mysql_query

2010-06-02 Thread Jim Lucas

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.



Break it down the basic of examples.

show us how you...

1. connect to mysql from php
2. select your database in mysql from php
3. prepare the SQL query
4. executing said query
5. collecting/displaying the results of executed query


As you can see, you gave us step 3.  The problem could be in any of the 
other setups.


--
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php