0
New Here
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/td-p/851841
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Ok guys im new to php mysql and i'm trying to insert some
form information in my database. Im using a script from sitepoint
in which i went through the tutorial did some experiments of my own
and it worked....
but now i'm getting this error which i cant figure out....
Error placing order: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order SET product ='1', size='medium', color='', quantity = '1' at line 1
here is the page
http://vaughntucker.com/imagecon/hats.php
and this is the script
<?php
//default page display
//connect to database
$dbcnx = @MySQL_connect('p3nl41mysql7.secureserver.net', 'imagecon', 'Dub*boss_1');
if (!$dbcnx) {
echo '<p> Unable to connect to the '. 'database server at this time.</p>';
exit();
}
//select database
if (!@mysql_select_db('imagecon')) {
exit('<p>Unable to locate the ' .
'database at this time.</p>');
}
//Mysql query add joke
if (isset($_POST['submit'])) {
$product = 1;
$size = $_POST['size'];
$color = $_POST['color'];
$quan = $_POST['quantity'];
$sql = "INSERT INTO order SET
product ='$product',
size='$size',
color='$color',
quantity = '$quan',
date = CURDATE()";
}else{
echo 'No data submited';
}
if (@mysql_query($sql)) {
echo '<p>Your order has been submited.</p>';
} else {
echo '<p>Error placing order: ' .
mysql_error() . '</p>';
}
?>
thanks in advance
but now i'm getting this error which i cant figure out....
Error placing order: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order SET product ='1', size='medium', color='', quantity = '1' at line 1
here is the page
http://vaughntucker.com/imagecon/hats.php
and this is the script
<?php
//default page display
//connect to database
$dbcnx = @MySQL_connect('p3nl41mysql7.secureserver.net', 'imagecon', 'Dub*boss_1');
if (!$dbcnx) {
echo '<p> Unable to connect to the '. 'database server at this time.</p>';
exit();
}
//select database
if (!@mysql_select_db('imagecon')) {
exit('<p>Unable to locate the ' .
'database at this time.</p>');
}
//Mysql query add joke
if (isset($_POST['submit'])) {
$product = 1;
$size = $_POST['size'];
$color = $_POST['color'];
$quan = $_POST['quantity'];
$sql = "INSERT INTO order SET
product ='$product',
size='$size',
color='$color',
quantity = '$quan',
date = CURDATE()";
}else{
echo 'No data submited';
}
if (@mysql_query($sql)) {
echo '<p>Your order has been submited.</p>';
} else {
echo '<p>Error placing order: ' .
mysql_error() . '</p>';
}
?>
thanks in advance
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
LEGEND
,
Dec 05, 2008
Dec 05, 2008
Murray *ACE* wrote:
> $sql = "INSERT INTO order SET
> product ='" . $product . "',
> size='" . $size . "',
> color='" . $color . "',
> quantity = '" . $quan . "',
No, that's not what's causing the problem. It's the use of "order" as
the table name. Order is a SQL reserved word. Either the table name
should be changed, or the INSERT query rewritten like this:
$size = mysql_real_escape_string($_POST['size']);
$color = mysql_real_escape_string($_POST['color']);
$quan = mysql_real_escape_string(...
> $sql = "INSERT INTO order SET
> product ='" . $product . "',
> size='" . $size . "',
> color='" . $color . "',
> quantity = '" . $quan . "',
No, that's not what's causing the problem. It's the use of "order" as
the table name. Order is a SQL reserved word. Either the table name
should be changed, or the INSERT query rewritten like this:
$size = mysql_real_escape_string($_POST['size']);
$color = mysql_real_escape_string($_POST['color']);
$quan = mysql_real_escape_string(...
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851842#M133966
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
$sql = "INSERT INTO order SET
product ='" . $product . "',
size='" . $size . "',
color='" . $color . "',
quantity = '" . $quan . "',
I believe there are other more elegant ways to do this, as well.
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"beatzMalone" <webforumsuser@macromedia.com> wrote in message
news:ghbiup$5s3$1@forums.macromedia.com...
> Ok guys im new to php mysql and i'm trying to insert some form information
> in
> my database. Im using a script from sitepoint in which i went through the
> tutorial did some experiments of my own and it worked....
>
> but now i'm getting this error which i cant figure out....
>
> Error placing order: You have an error in your SQL syntax; check the
> manual
> that corresponds to your MySQL server version for the right syntax to use
> near
> 'order SET product ='1', size='medium', color='', quantity = '1' at line 1
>
> here is the page
> http://vaughntucker.com/imagecon/hats.php
>
> and this is the script
> <?php
> //default page display
> //connect to database
> $dbcnx = @mysql_connect('p3nl41mysql7.secureserver.net', 'imagecon',
> 'Dub*boss_1');
> if (!$dbcnx) {
> echo '<p> Unable to connect to the '. 'database server at this
> time.</p>';
> exit();
>
> }
>
> //select database
> if (!@mysql_select_db('imagecon')) {
> exit('<p>Unable to locate the ' .
> 'database at this time.</p>');
> }
>
> //Mysql query add joke
> if (isset($_POST['submit'])) {
> $product = 1;
> $size = $_POST['size'];
> $color = $_POST['color'];
> $quan = $_POST['quantity'];
> $sql = "INSERT INTO order SET
> product ='$product',
> size='$size',
> color='$color',
> quantity = '$quan',
> date = CURDATE()";
> }else{
> echo 'No data submited';
>
> }
> if (@mysql_query($sql)) {
> echo '<p>Your order has been submited.</p>';
> } else {
> echo '<p>Error placing order: ' .
> mysql_error() . '</p>';
> }
>
>
>
> ?>
>
> thanks in advance
>
product ='" . $product . "',
size='" . $size . "',
color='" . $color . "',
quantity = '" . $quan . "',
I believe there are other more elegant ways to do this, as well.
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"beatzMalone" <webforumsuser@macromedia.com> wrote in message
news:ghbiup$5s3$1@forums.macromedia.com...
> Ok guys im new to php mysql and i'm trying to insert some form information
> in
> my database. Im using a script from sitepoint in which i went through the
> tutorial did some experiments of my own and it worked....
>
> but now i'm getting this error which i cant figure out....
>
> Error placing order: You have an error in your SQL syntax; check the
> manual
> that corresponds to your MySQL server version for the right syntax to use
> near
> 'order SET product ='1', size='medium', color='', quantity = '1' at line 1
>
> here is the page
> http://vaughntucker.com/imagecon/hats.php
>
> and this is the script
> <?php
> //default page display
> //connect to database
> $dbcnx = @mysql_connect('p3nl41mysql7.secureserver.net', 'imagecon',
> 'Dub*boss_1');
> if (!$dbcnx) {
> echo '<p> Unable to connect to the '. 'database server at this
> time.</p>';
> exit();
>
> }
>
> //select database
> if (!@mysql_select_db('imagecon')) {
> exit('<p>Unable to locate the ' .
> 'database at this time.</p>');
> }
>
> //Mysql query add joke
> if (isset($_POST['submit'])) {
> $product = 1;
> $size = $_POST['size'];
> $color = $_POST['color'];
> $quan = $_POST['quantity'];
> $sql = "INSERT INTO order SET
> product ='$product',
> size='$size',
> color='$color',
> quantity = '$quan',
> date = CURDATE()";
> }else{
> echo 'No data submited';
>
> }
> if (@mysql_query($sql)) {
> echo '<p>Your order has been submited.</p>';
> } else {
> echo '<p>Error placing order: ' .
> mysql_error() . '</p>';
> }
>
>
>
> ?>
>
> thanks in advance
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851843#M133967
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Murray *ACE* wrote:
> $sql = "INSERT INTO order SET
> product ='" . $product . "',
> size='" . $size . "',
> color='" . $color . "',
> quantity = '" . $quan . "',
No, that's not what's causing the problem. It's the use of "order" as
the table name. Order is a SQL reserved word. Either the table name
should be changed, or the INSERT query rewritten like this:
$size = mysql_real_escape_string($_POST['size']);
$color = mysql_real_escape_string($_POST['color']);
$quan = mysql_real_escape_string($_POST['quantity']);
$sql = "INSERT INTO `order` SET
product = 1,
size= '$size',
color= '$color',
quantity = $quan,
`date` = CURDATE()";
Note that I have surrounded order and date with backticks. I have also
removed $product, since it has a fixed value. I removed the quotes from
around $quan, because numbers should not be quoted in SQL queries.
The changes I have made assume that magic quotes are turned off on the
server. If they are on, you also need to pass the $_POST variables to
stripslashes() like this:
$size = mysql_real_escape_string(stripslashes($_POST['size']));
$color = mysql_real_escape_string(stripslashes($_POST['color']));
$quan = mysql_real_escape_string(stripslashes($_POST['quantity']);
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
> $sql = "INSERT INTO order SET
> product ='" . $product . "',
> size='" . $size . "',
> color='" . $color . "',
> quantity = '" . $quan . "',
No, that's not what's causing the problem. It's the use of "order" as
the table name. Order is a SQL reserved word. Either the table name
should be changed, or the INSERT query rewritten like this:
$size = mysql_real_escape_string($_POST['size']);
$color = mysql_real_escape_string($_POST['color']);
$quan = mysql_real_escape_string($_POST['quantity']);
$sql = "INSERT INTO `order` SET
product = 1,
size= '$size',
color= '$color',
quantity = $quan,
`date` = CURDATE()";
Note that I have surrounded order and date with backticks. I have also
removed $product, since it has a fixed value. I removed the quotes from
around $quan, because numbers should not be quoted in SQL queries.
The changes I have made assume that magic quotes are turned off on the
server. If they are on, you also need to pass the $_POST variables to
stripslashes() like this:
$size = mysql_real_escape_string(stripslashes($_POST['size']));
$color = mysql_real_escape_string(stripslashes($_POST['color']));
$quan = mysql_real_escape_string(stripslashes($_POST['quantity']);
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851844#M133968
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
<sigh>
Thanks, David! 8)
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbnbq$b1m$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> $sql = "INSERT INTO order SET
>> product ='" . $product . "',
>> size='" . $size . "',
>> color='" . $color . "',
>> quantity = '" . $quan . "',
>
> No, that's not what's causing the problem. It's the use of "order" as the
> table name. Order is a SQL reserved word. Either the table name should be
> changed, or the INSERT query rewritten like this:
>
> $size = mysql_real_escape_string($_POST['size']);
> $color = mysql_real_escape_string($_POST['color']);
> $quan = mysql_real_escape_string($_POST['quantity']);
> $sql = "INSERT INTO `order` SET
> product = 1,
> size= '$size',
> color= '$color',
> quantity = $quan,
> `date` = CURDATE()";
> Note that I have surrounded order and date with backticks. I have also
> removed $product, since it has a fixed value. I removed the quotes from
> around $quan, because numbers should not be quoted in SQL queries.
>
> The changes I have made assume that magic quotes are turned off on the
> server. If they are on, you also need to pass the $_POST variables to
> stripslashes() like this:
>
> $size = mysql_real_escape_string(stripslashes($_POST['size']));
> $color = mysql_real_escape_string(stripslashes($_POST['color']));
> $quan = mysql_real_escape_string(stripslashes($_POST['quantity']);
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
Thanks, David! 8)
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbnbq$b1m$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> $sql = "INSERT INTO order SET
>> product ='" . $product . "',
>> size='" . $size . "',
>> color='" . $color . "',
>> quantity = '" . $quan . "',
>
> No, that's not what's causing the problem. It's the use of "order" as the
> table name. Order is a SQL reserved word. Either the table name should be
> changed, or the INSERT query rewritten like this:
>
> $size = mysql_real_escape_string($_POST['size']);
> $color = mysql_real_escape_string($_POST['color']);
> $quan = mysql_real_escape_string($_POST['quantity']);
> $sql = "INSERT INTO `order` SET
> product = 1,
> size= '$size',
> color= '$color',
> quantity = $quan,
> `date` = CURDATE()";
> Note that I have surrounded order and date with backticks. I have also
> removed $product, since it has a fixed value. I removed the quotes from
> around $quan, because numbers should not be quoted in SQL queries.
>
> The changes I have made assume that magic quotes are turned off on the
> server. If they are on, you also need to pass the $_POST variables to
> stripslashes() like this:
>
> $size = mysql_real_escape_string(stripslashes($_POST['size']));
> $color = mysql_real_escape_string(stripslashes($_POST['color']));
> $quan = mysql_real_escape_string(stripslashes($_POST['quantity']);
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851845#M133969
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Murray *ACE* wrote:
> <sigh>
>
> Thanks, David! 8)
No problemo. The approach you took is normally the right one. However,
what gave the game away to me was the original error message, which made
me think that an ORDER BY clause had been put in the wrong place. It was
then that the penny dropped about "order" being a reserved word.
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
> <sigh>
>
> Thanks, David! 8)
No problemo. The approach you took is normally the right one. However,
what gave the game away to me was the original error message, which made
me think that an ORDER BY clause had been put in the wrong place. It was
then that the penny dropped about "order" being a reserved word.
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851846#M133970
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Yeah - I can see how that process worked. So, the use of the
$variable
within single quotes within double quotes is OK? That will save me some
trouble!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbo8q$bv2$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> <sigh>
>>
>> Thanks, David! 8)
>
> No problemo. The approach you took is normally the right one. However,
> what gave the game away to me was the original error message, which made
> me think that an ORDER BY clause had been put in the wrong place. It was
> then that the penny dropped about "order" being a reserved word.
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
within single quotes within double quotes is OK? That will save me some
trouble!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbo8q$bv2$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> <sigh>
>>
>> Thanks, David! 8)
>
> No problemo. The approach you took is normally the right one. However,
> what gave the game away to me was the original error message, which made
> me think that an ORDER BY clause had been put in the wrong place. It was
> then that the penny dropped about "order" being a reserved word.
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851847#M133971
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Yes. Usually I like to throw in some curly brackets (more to
clarify
exactly what the variable is, but can also hit object properties or
array indexes)...
"...
`name`='{$dbData['name']}',
`rodent`='{$hamster}'
..."
...some might consider that overkill for simple variables though. I can
be a bit compulsive.
Murray *ACE* wrote:
> Yeah - I can see how that process worked. So, the use of the $variable
> within single quotes within double quotes is OK? That will save me some
> trouble!
>
exactly what the variable is, but can also hit object properties or
array indexes)...
"...
`name`='{$dbData['name']}',
`rodent`='{$hamster}'
..."
...some might consider that overkill for simple variables though. I can
be a bit compulsive.
Murray *ACE* wrote:
> Yeah - I can see how that process worked. So, the use of the $variable
> within single quotes within double quotes is OK? That will save me some
> trouble!
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851848#M133972
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Murray *ACE* wrote:
> So, the use of the $variable
> within single quotes within double quotes is OK?
Yes. A lot of people get mixed up with the use of quotes in PHP, but the
rules are very simple:
1. Anything inside double quotes is interpreted.
2. Anything inside single quotes is treated as plain text.
3. The outermost pair of quotes determines which rule applies.
Example:
$name = 'Murray';
echo "$name Summers"; // displays "Murray Summers"
echo "His name is '$name'."; // displays "His name is 'Murray'."
echo '$name Summers'; // displays "$name Summers".
echo 'His name is "$name".'; // displays "His name is "$name"."
Many people use double quotes all the time, and create finger-twisting
(and illegible) code with backslashes. Best practice is to mix single
and double quotes for readability:
http://framework.zend.com/manual/en/coding-standard.coding-style.html#coding-standard.coding-style.s...
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
> So, the use of the $variable
> within single quotes within double quotes is OK?
Yes. A lot of people get mixed up with the use of quotes in PHP, but the
rules are very simple:
1. Anything inside double quotes is interpreted.
2. Anything inside single quotes is treated as plain text.
3. The outermost pair of quotes determines which rule applies.
Example:
$name = 'Murray';
echo "$name Summers"; // displays "Murray Summers"
echo "His name is '$name'."; // displays "His name is 'Murray'."
echo '$name Summers'; // displays "$name Summers".
echo 'His name is "$name".'; // displays "His name is "$name"."
Many people use double quotes all the time, and create finger-twisting
(and illegible) code with backslashes. Best practice is to mix single
and double quotes for readability:
http://framework.zend.com/manual/en/coding-standard.coding-style.html#coding-standard.coding-style.s...
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851849#M133973
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Thanks, Nate. That was the method I was trying to remember,
but was not
sure about the exact details of the use of the curlies.
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"Nate Baldwin" <fake@example.com> wrote in message
news:ghbpq5$e79$1@forums.macromedia.com...
> Yes. Usually I like to throw in some curly brackets (more to clarify
> exactly what the variable is, but can also hit object properties or array
> indexes)...
>
> "...
> `name`='{$dbData['name']}',
> `rodent`='{$hamster}'
> ..."
>
> ...some might consider that overkill for simple variables though. I can be
> a bit compulsive.
>
> Murray *ACE* wrote:
>> Yeah - I can see how that process worked. So, the use of the $variable
>> within single quotes within double quotes is OK? That will save me some
>> trouble!
>>
sure about the exact details of the use of the curlies.
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"Nate Baldwin" <fake@example.com> wrote in message
news:ghbpq5$e79$1@forums.macromedia.com...
> Yes. Usually I like to throw in some curly brackets (more to clarify
> exactly what the variable is, but can also hit object properties or array
> indexes)...
>
> "...
> `name`='{$dbData['name']}',
> `rodent`='{$hamster}'
> ..."
>
> ...some might consider that overkill for simple variables though. I can be
> a bit compulsive.
>
> Murray *ACE* wrote:
>> Yeah - I can see how that process worked. So, the use of the $variable
>> within single quotes within double quotes is OK? That will save me some
>> trouble!
>>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851850#M133974
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Thanks. It was that #3 rule I wasn't aware of. This will
indeed make my
life easier, and my code less eye-popping!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbqcf$esi$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> So, the use of the $variable within single quotes within double quotes is
>> OK?
>
> Yes. A lot of people get mixed up with the use of quotes in PHP, but the
> rules are very simple:
>
> 1. Anything inside double quotes is interpreted.
> 2. Anything inside single quotes is treated as plain text.
> 3. The outermost pair of quotes determines which rule applies.
>
> Example:
>
> $name = 'Murray';
> echo "$name Summers"; // displays "Murray Summers"
> echo "His name is '$name'."; // displays "His name is 'Murray'."
> echo '$name Summers'; // displays "$name Summers".
> echo 'His name is "$name".'; // displays "His name is "$name"."
>
> Many people use double quotes all the time, and create finger-twisting
> (and illegible) code with backslashes. Best practice is to mix single and
> double quotes for readability:
>
> http://framework.zend.com/manual/en/coding-standard.coding-style.html#coding-standard.coding-style.s...
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
life easier, and my code less eye-popping!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbqcf$esi$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> So, the use of the $variable within single quotes within double quotes is
>> OK?
>
> Yes. A lot of people get mixed up with the use of quotes in PHP, but the
> rules are very simple:
>
> 1. Anything inside double quotes is interpreted.
> 2. Anything inside single quotes is treated as plain text.
> 3. The outermost pair of quotes determines which rule applies.
>
> Example:
>
> $name = 'Murray';
> echo "$name Summers"; // displays "Murray Summers"
> echo "His name is '$name'."; // displays "His name is 'Murray'."
> echo '$name Summers'; // displays "$name Summers".
> echo 'His name is "$name".'; // displays "His name is "$name"."
>
> Many people use double quotes all the time, and create finger-twisting
> (and illegible) code with backslashes. Best practice is to mix single and
> double quotes for readability:
>
> http://framework.zend.com/manual/en/coding-standard.coding-style.html#coding-standard.coding-style.s...
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851851#M133975
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Murray *ACE* wrote:
> Thanks. It was that #3 rule I wasn't aware of. This will indeed make
> my life easier, and my code less eye-popping!
Nate's suggestion about using curlies is also important when embedding
array elements in a double quoted string:
This works:
echo "You selected {$_POST['product']}";
This triggers a parse error:
echo "You selected $_POST['product']";
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
> Thanks. It was that #3 rule I wasn't aware of. This will indeed make
> my life easier, and my code less eye-popping!
Nate's suggestion about using curlies is also important when embedding
array elements in a double quoted string:
This works:
echo "You selected {$_POST['product']}";
This triggers a parse error:
echo "You selected $_POST['product']";
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851852#M133976
Dec 05, 2008
Dec 05, 2008
Copy link to clipboard
Copied
Thanks!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbr5b$fk2$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Thanks. It was that #3 rule I wasn't aware of. This will indeed make my
>> life easier, and my code less eye-popping!
>
> Nate's suggestion about using curlies is also important when embedding
> array elements in a double quoted string:
>
> This works:
>
> echo "You selected {$_POST['product']}";
>
> This triggers a parse error:
>
> echo "You selected $_POST['product']";
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"David Powers" <david@example.com> wrote in message
news:ghbr5b$fk2$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Thanks. It was that #3 rule I wasn't aware of. This will indeed make my
>> life easier, and my code less eye-popping!
>
> Nate's suggestion about using curlies is also important when embedding
> array elements in a double quoted string:
>
> This works:
>
> echo "You selected {$_POST['product']}";
>
> This triggers a parse error:
>
> echo "You selected $_POST['product']";
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS4",
> "PHP Solutions" & "PHP Object-Oriented Solutions"
> http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
beatzMalone
AUTHOR
New Here
,
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851853#M133977
Dec 06, 2008
Dec 06, 2008
Copy link to clipboard
Copied
wow a whole days worth of class room lessons from one
question...
Awesome guys thanx alot it works now..
Awesome guys thanx alot it works now..
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/dreamweaver-discussions/help-with-php-mysql-connect-script/m-p/851854#M133978
Dec 06, 2008
Dec 06, 2008
Copy link to clipboard
Copied
Stick around. There's lots of good stuff here!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"beatzMalone" <webforumsuser@macromedia.com> wrote in message
news:ghf8oo$p6t$1@forums.macromedia.com...
> wow a whole days worth of class room lessons from one question...
>
> Awesome guys thanx alot it works now..
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"beatzMalone" <webforumsuser@macromedia.com> wrote in message
news:ghf8oo$p6t$1@forums.macromedia.com...
> wow a whole days worth of class room lessons from one question...
>
> Awesome guys thanx alot it works now..
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

