Re: [PHP] Single/Double Quotes

2001-12-12 Thread Konrad Riedel

Am Wed, 12.Dec  2001 um 10:22 schrieb Miles Thompson:
> This should work ...
> $result=mysql_query("SELECT book FROM TAB_AUTHORS  WHERE aid = '$aid'");
> 
> When PHP sees the single quotes around the $aid it evaluates it to the 
> value stored in the variable.
> Your first example connntained $aid within a set of double quotes, thus it 
> was treated as a literal.
No, $aid is evaluated in both cases, but SQL-Syntax requires the quotes!
...WHERE aid = 'xyz'


Mit freundlichen Grüßen
Konrad Riedel

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Single/Double Quotes

2001-12-12 Thread Kevin Stone

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" <[EMAIL PROTECTED]>
To: "PHP" <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Single/Double Quotes

2001-12-12 Thread Miles Thompson

This should work ...
$result=mysql_query("SELECT book FROM TAB_AUTHORS  WHERE aid = '$aid'");

When PHP sees the single quotes around the $aid it evaluates it to the 
value stored in the variable.
Your first example connntained $aid within a set of double quotes, thus it 
was treated as a literal.

Hope this helps - Miles Thompson

At 09:08 AM 12/12/2001 -0500, Gerard Samuel wrote:
>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: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Single/Double Quotes

2001-12-12 Thread Gerard Samuel

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]