> -----Original Message-----
> From: Jonathan Underfoot [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 10, 2001 2:55 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] A Real PHP problem for a change...
> 
> 
> That said, (Now on to actual PHP) I've noticed (in my own 
> scripting) and a few other problems posted here quite a bit
> of confusion with PHP's single ' and double " quotes.  Reading
> the material I was led to believe that
>       '   ' outputs exactly what is in the quotes and
>       "   " outputs variables and strings (etc..)
> Thus I become radically confused by this recent comment to 
> use '"$uname"'. 

I didn't see the context of the above comment, but

        <?php echo '"$uname"'; ?>

does exactly what I'd expect it to do based on the above rules.  It
outputs the literal string

        "$uname"

> And furthermore the solutions to one of my MySql query 
> problems being adding single quotes ' ' to all the variables. 

Yep.  MySQL (and, in fact, just about any database) likes to have
non-numeric values quoted in a query string.

> Now by my understanding, thats not supposed to work. 

Here, I think, is where we can clear things up for you a bit by
explaining that the important quotes, the ones that determine which of
the two behaviors you listed will apply, are the *outermost* ones.

So...

        <?php
                $var1 = "cookies";
                $var2 = "milk";

                echo "$var1"; // outputs: cookies
                echo '$var2'; // outputs: $var2
                echo "I like '$var1'"; // outputs: I like 'cookies'
                echo '"$var2"'; // outputs: "$var2"
                echo "'Got $var2?'"; // outputs: 'Got milk?'
        ?>

Get the idea?


---
Mark Roedel           | "The most overlooked advantage to owning a
Systems Programmer    |  computer is that if they foul up there's no
LeTourneau University |  law against whacking them around a little."
Longview, Texas, USA  |                          -- Owen Porterfield 

--
PHP Database 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]

Reply via email to