Jump to content

[SOLVED] What's wrong with this query?


jim.davidson

Recommended Posts

OOps forgot,

I'm running mySql ver 4.1.21

I'm running this through dreamweaver

 

I get this error but don't see the problem

 

Parse error: parse error, unexpected T_STRING

 

If I remove this section of code, I have no problem

 

mysql_select_db($database_imcrecycle, $imcrecycle);

$query_getCustomerId = "SELECT customers.customer_id FROM customers WHERE customers.state_id="ZZ"";

$getCustomerId = mysql_query($query_getCustomerId, $imcrecycle) or die(mysql_error());

$row_getCustomerId = mysql_fetch_assoc($getCustomerId);

$totalRows_getCustomerId = mysql_num_rows($getCustomerId);

 

Another thing, why can't I see an earlier post of mine. I posted a question about an hour and a half ago and I can't find it?

Link to comment
https://forums.phpfreaks.com/topic/45435-solved-whats-wrong-with-this-query/
Share on other sites

 

You need to escape the double quotes within the double quotes.

 

$query_getCustomerId = "SELECT customers.customer_id FROM customers WHERE customers.state_id="ZZ"";

...should be either...

$query_getCustomerId = "SELECT customers.customer_id FROM customers WHERE customers.state_id=\"ZZ\"";  // escaped double quotes

...or...

$query_getCustomerId = "SELECT customers.customer_id FROM customers WHERE customers.state_id='ZZ'";  // single quotes

...or even...

$query_getCustomerId = 'SELECT customers.customer_id FROM customers WHERE customers.state_id="ZZ"';

 

(Your other post is in PHP Help.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.