Solved

Getting parse error in sql statement

Posted on 2007-03-22
31
222 Views
Last Modified: 2007-03-22
I getting a parse error in my sql statement.  Could someone tell me what I missed?

$SQL = mysql_query("UPDATE tblAdspace SET "
       $SQL = $SQL . "strProviderservice = '" . $strProviderservice . "', "  <--- Parse error
     $SQL = $SQL . "strCompanyname='" . $strCompanyname . "', "
     $SQL = $SQL . "strOwner='" . $strOwner . "', "
       $SQL = $SQL . "strAddress='" . $strAddress . "', "
     $SQL = $SQL . "strTown='" . $strTown . "', "
       $SQL = $SQL . "strZipcode='" . $strZipcode . "', "
       $SQL = $SQL . "strPhone='" . $strPhone . "', "
     $SQL = $SQL . "str2ndphone='" . $str2ndphone . "', "
     $SQL = $SQL . "strMobile='" . $strMobile . "', "
     $SQL = $SQL . "strPager='" . $strPager . "', "
     $SQL = $SQL . "strFax='" . $strFax . "', "
     $SQL = $SQL . "strEmail='" . $strEmail . "', "
     $SQL = $SQL . "strWebsite='" . $strWebsite . "', "
     $SQL = $SQL . "strLicense='" . $strLicense . "', "
     $SQL = $SQL . "strInsured='" . $strInsured . "', "
     $SQL = $SQL . "strBonded='" . $strBonded . "', "
     $SQL = $SQL . "strHours='" . $strHours . "', "
     $SQL = $SQL . "str24houremerg='" . $str24houremerg . "', "
     $SQL = $SQL . "strOtherServices='" . str_replace(str_replace("'","''", $strOtherservices), "vbcrlf", "<br>") . "', "
     $SQL = $SQL . "strServicearea='" . $strServicearea . "', "
     $SQL = $SQL . "strInbusiness_since='" . $strInbusiness_since . "', "
     $SQL = $SQL . " strServicesOffered='" . str_replace(str_replace("'","''", $strServicesoffered), "vbcrlf", "<br>") . "', "
       $SQL = $SQL . "strFreeestimate='" . $strFreeestimate . "', "
     $SQL = $SQL . "strWorkguaranteed='" . $strWorkguaranteed . "', "
       $SQL = $SQL . "strProvidertagline='" . str_replace(str_replace("'", "''", $strProvidertagline), "vbcrlf", "<br>") . "', " 
     $SQL = $SQL . "strAd_size='" . $strAd_size . "', "
       $SQL = $SQL . "strImage='" . strImage . "'"
     $SQL = $SQL . " WHERE strCompanyname = '" . strCompanyname . "'");
}
0
Comment
Question by:pingeyeg
  • 14
  • 10
  • 7
31 Comments
 
LVL 24

Expert Comment

by:glcummins
ID: 18771385
Can you try this:

$SQL = mysql_query("UPDATE tblAdspace SET "
       . "strProviderservice = '" . $strProviderservice . "', "
     . "strCompanyname='" . $strCompanyname . "', "
     . "strOwner='" . $strOwner . "', "
       . "strAddress='" . $strAddress . "', "
     . "strTown='" . $strTown . "', "
       . "strZipcode='" . $strZipcode . "', "
       . "strPhone='" . $strPhone . "', "
     . "str2ndphone='" . $str2ndphone . "', "
     . "strMobile='" . $strMobile . "', "
     . "strPager='" . $strPager . "', "
     . "strFax='" . $strFax . "', "
     . "strEmail='" . $strEmail . "', "
     . "strWebsite='" . $strWebsite . "', "
     . "strLicense='" . $strLicense . "', "
     . "strInsured='" . $strInsured . "', "
     . "strBonded='" . $strBonded . "', "
     . "strHours='" . $strHours . "', "
     . "str24houremerg='" . $str24houremerg . "', "
     . "strOtherServices='" . str_replace(str_replace("'","''", $strOtherservices), "vbcrlf", "<br>") . "', "
     . "strServicearea='" . $strServicearea . "', "
     . "strInbusiness_since='" . $strInbusiness_since . "', "
     . " strServicesOffered='" . str_replace(str_replace("'","''", $strServicesoffered), "vbcrlf", "<br>") . "', "
       . "strFreeestimate='" . $strFreeestimate . "', "
     . "strWorkguaranteed='" . $strWorkguaranteed . "', "
       . "strProvidertagline='" . str_replace(str_replace("'", "''", $strProvidertagline), "vbcrlf", "<br>") . "', "
     . "strAd_size='" . $strAd_size . "', "
       . "strImage='" . strImage . "'"
     . " WHERE strCompanyname = '" . strCompanyname . "'");
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771418
Not sure what's going on now because the error message is on a perfectly good line.  Below is the entire update page.

<?php

if ($_SERVER['REQUEST_METHOD'] == "POST") {

$conn = mysql_connect("", "", "");
mysql_select_db("providers", $conn);

            $strProviderservice = $_REQUEST['strProviderservice'];
            $strCompanyname = $_REQUEST['strCompanyname'];
            $strOwner = $_REQUEST['strOwner'];
            $strAddress = $_REQUEST['strAddress'];
            $strTown = $_REQUEST['strTown'];
            $strZipcode = $_REQUEST['strZipcode'];
            $strPhone = $_REQUEST['strPhone'];
            $str2ndphone = $_REQUEST['str2ndphone'];
            $strMobile = $_REQUEST['strMobile'];
            $strPager = $_REQUEST['strPager'];
            $strFax = $_REQUEST['strFax'];
            $strEmail = $_REQUEST['strEmail'];
            $strWebsite = $_REQUEST['strWebsite'];
            $strInbusiness_since = $_REQUEST['strInbusiness_since'];
            $strLicense = $_REQUEST['strLicense'];
            $strInsured = $_REQUEST['strInsured'];
            $strBonded = $_REQUEST['strBonded'];
            $strHours = $_REQUEST['strHours'];
            $str24houremerg = $_REQUEST['str24houremerg'];
            $strServicesoffered = $_REQUEST['strServicesoffered'];
            $strOtherservices = $_REQUEST['strOtherservices'];
            $strServicearea = $_REQUEST['strServicearea'];
            $strFreeestimate = $_REQUEST['strFreeestimate'];
            $strWorkguaranteed = $_REQUEST['strWorkguaranteed'];
            $strProvidertagline = $_REQUEST['strProvidertagline'];
            $strAd_size = $_REQUEST['strAd_size'];

$SQL = mysql_query("SELECT * FROM tblAdspace where strCompanyname = '" .$strCompanyname. "'");

if ($row = mysql_fetch_array($SQL)) {

$SQL = mysql_query("UPDATE tblAdspace SET "
       . "strProviderservice = '" . $strProviderservice . "', "
     . "strCompanyname='" . $strCompanyname . "', "
     . "strOwner='" . $strOwner . "', "
       . "strAddress='" . $strAddress . "', "
     . "strTown='" . $strTown . "', "
       . "strZipcode='" . $strZipcode . "', "
       . "strPhone='" . $strPhone . "', "
     . "str2ndphone='" . $str2ndphone . "', "
     . "strMobile='" . $strMobile . "', "
     . "strPager='" . $strPager . "', "
     . "strFax='" . $strFax . "', "
     . "strEmail='" . $strEmail . "', "
     . "strWebsite='" . $strWebsite . "', "
     . "strLicense='" . $strLicense . "', "
     . "strInsured='" . $strInsured . "', "
     . "strBonded='" . $strBonded . "', "
     . "strHours='" . $strHours . "', "
     . "str24houremerg='" . $str24houremerg . "', "
     . "strOtherServices='" . str_replace(str_replace("'","''", $strOtherservices), "vbcrlf", "<br>") . "', "
     . "strServicearea='" . $strServicearea . "', "
     . "strInbusiness_since='" . $strInbusiness_since . "', "
     . " strServicesOffered='" . str_replace(str_replace("'","''", $strServicesoffered), "vbcrlf", "<br>") . "', "
       . "strFreeestimate='" . $strFreeestimate . "', "
     . "strWorkguaranteed='" . $strWorkguaranteed . "', "
       . "strProvidertagline='" . str_replace(str_replace("'", "''", $strProvidertagline), "vbcrlf", "<br>") . "', "
     . "strAd_size='" . $strAd_size . "', "
       . "strImage='" . strImage . "'"
     . " WHERE strCompanyname = '" . strCompanyname . "'");
                    
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
"<head>\n";
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n";
"<title>Ask2bsure.com - (Admin Section) Edit Provider</title>\n";
"<link style=\"text/css\" href=\"/css/style.css\" rel=\"stylesheet\">\n";
"</head>\n";
"<body>\n";
"<table align=\"center\" id=\"admin\">\n";
"<tr><td align=\"center\" colspan=\"2\">\n";
"<img src=\"/images/sublogo_2.png\"><br />\n";
"<span style=\"font-size: 12px; color: #0000FF\">(Admin Section)</span>\n";
"</td></tr>\n";
"<tr><td valign=\"top\">\n";
"<div id=\"navlist\">\n";
"<a href=\"/admin/\">Home</a>\n";
"<a href=\"/admin/add_provider.php\">Add Provider</a>\n";
"<a href=\"/admin/list_providers.php?list=list\">Delete / Edit Provider</a>\n";
"<a href=\"/admin/list_providers.php?review=review\">Toggle / Edit Reviews</a>\n";
"<a href=\"/index.php\">Back To Website</a>\n";
"</div>\n";
"</td><td width=\"625\">\n";
"<table id=\"main_admin\" align=\"center\" border=\"0\">\n";
"<tr><td align=\"center\">\n";
"The selected provider has now been updated.\n";
"</td></tr>\n";
"</table>\n";
"</td></tr>\n";
"</table>\n";
"</body>\n";
"</html>"

} else {
     $SQL = mysql_query("INSERT INTO tblAdspace "
     $SQL = $SQL . "("
     $SQL = $SQL . "strProviderservice, strCompanyname, strOwner, strAddress, strTown, "
     $SQL = $SQL . "strZipcode, strPhone, str2ndphone, "
     $SQL = $SQL . "strMobile, strPager, strFax, "
     $SQL = $SQL . "strEmail, strWebsite, strLicense, "
     $SQL = $SQL . "strBonded, strHours, str24houremerg, "
     $SQL = $SQL . "strOtherservices, strServicearea, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size"
if ($strimage <> "") {
        $SQL = $SQL . ", strimage "
}

      $SQL = $SQL . ") "
      $SQL = $SQL . "VALUES("
      $SQL = $SQL . "'" . $strProviderservice . "',"
      $SQL = $SQL . "'" . $strCompanyname . "',"
      $SQL = $SQL . "'" . $strOwner . "',"
      $SQL = $SQL . "'" . $strAddress . "',"
      $SQL = $SQL . "'" . $strTown . "',"
      $SQL = $SQL . "'" . $strZipcode . "',"
      $SQL = $SQL . "'" . $strPhone . "',"
      $SQL = $SQL . "'" . $str2ndphone . "',"
      $SQL = $SQL . "'" . $strMobile . "',"
      $SQL = $SQL . "'" . $strPager . "',"
      $SQL = $SQL . "'" . $strFax . "',"
      $SQL = $SQL . "'" . $strEmail . "',"
      $SQL = $SQL . "'" . $strWebsite . "',"
      $SQL = $SQL . "'" . $strLicense . "',"
      $SQL = $SQL . "'" . $strBonded . "',"
      $SQL = $SQL . "'" . $strHours . "',"
      $SQL = $SQL . "'" . $str24houremerg . "',"
      $SQL = $SQL . "'" . str_replace("'", "''", $strOtherservices) . "',"
      $SQL = $SQL . "'" . $strServicearea . "',"
      $SQL = $SQL . "'" . $strFreeestimate . "',"
      $SQL = $SQL . "'" . $strWorkguaranteed . "',"
      $SQL = $SQL . "'" . str_replace("'", "''", $strProvidertagline) . "',"
      $SQL = $SQL . "'" . $strAd_size . "'"
if ($strImage <> "") {
      $SQL = $SQL . ",'" . $strImage . "'"
}
      $SQL = $SQL . ") ");
}

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
"<head>\n";
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n";
"<title>Ask2bsure.com - (Admin Section) Edit Provider</title>\n";
"<link style=\"text/css\" href=\"/css/style.css\" rel=\"stylesheet\">\n";
"</head>\n";
"<body>\n";
"<table align=\"center\" id=\"admin\">\n";
"<tr><td align=\"center\" colspan=\"2\">\n";
"<img src=\"/images/sublogo_2.png\"><br />\n";
"<span style=\"font-size: 12px; color: #0000FF\">(Admin Section)</span>\n";
"</td></tr>\n";
"<tr><td valign=\"top\">\n";
"<div id=\"navlist\">\n";
"<a href=\"/admin/\">Home</a>\n";
"<a href=\"/admin/add_provider.php\">Add Provider</a>\n";
"<a href=\"/admin/list_providers.php?list=list\">Delete / Edit Provider</a>\n";
"<a href=\"/admin/list_providers.php?review=review\">Toggle / Edit Reviews</a>\n";
"<a href=\"/index.php\">Back To Website</a>\n";
"</div>\n";
"</td><td width=\"625\">\n";
"<table id=\"main_admin\" align=\"center\" border=\"0\">\n";
"<tr><td align=\"center\">\n";
"The selected provider has now been updated.\n";
"</td></tr>\n";
"</table>\n";
"</td></tr>\n";
"</table>\n";
"</body>\n";
"</html>"

}
}

?>      
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771431
The error occurs on the else statment halfway down the page.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Accepted Solution

by:
glcummins earned 400 total points
ID: 18771466
This is the same problem again. The '$SQL = $SQL .' statements are throwing you off. Try this:

     $SQL = mysql_query("INSERT INTO tblAdspace VALUES"
     . "("
     . "strProviderservice, strCompanyname, strOwner, strAddress, strTown, "
     . "strZipcode, strPhone, str2ndphone, "
     . "strMobile, strPager, strFax, "
     . "strEmail, strWebsite, strLicense, "
     . "strBonded, strHours, str24houremerg, "
     . "strOtherservices, strServicearea, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size"
if ($strimage <> "") {
        . ", strimage "

Also note that I added the word 'VALUES' on the first line of this update. You may have to alter other parts of your code in this manner. When you are creating the query within the parenthesis of the mysql_query() function, do not try to assign the string to the variable $SQL.
0
 
LVL 24

Assisted Solution

by:glcummins
glcummins earned 400 total points
ID: 18771476
Also, this:

      $SQL = $SQL . ") "
      $SQL = $SQL . "VALUES("
      $SQL = $SQL . "'" . $strProviderservice . "',"
      $SQL = $SQL . "'" . $strCompanyname . "',"
      $SQL = $SQL . "'" . $strOwner . "',"
      $SQL = $SQL . "'" . $strAddress . "',"
      $SQL = $SQL . "'" . $strTown . "',"
      $SQL = $SQL . "'" . $strZipcode . "',"
      $SQL = $SQL . "'" . $strPhone . "',"
      $SQL = $SQL . "'" . $str2ndphone . "',"
      $SQL = $SQL . "'" . $strMobile . "',"
      $SQL = $SQL . "'" . $strPager . "',"
      $SQL = $SQL . "'" . $strFax . "',"
      $SQL = $SQL . "'" . $strEmail . "',"
      $SQL = $SQL . "'" . $strWebsite . "',"
      $SQL = $SQL . "'" . $strLicense . "',"
      $SQL = $SQL . "'" . $strBonded . "',"
      $SQL = $SQL . "'" . $strHours . "',"
      $SQL = $SQL . "'" . $str24houremerg . "',"
      $SQL = $SQL . "'" . str_replace("'", "''", $strOtherservices) . "',"
      $SQL = $SQL . "'" . $strServicearea . "',"
      $SQL = $SQL . "'" . $strFreeestimate . "',"
      $SQL = $SQL . "'" . $strWorkguaranteed . "',"
      $SQL = $SQL . "'" . str_replace("'", "''", $strProvidertagline) . "',"
      $SQL = $SQL . "'" . $strAd_size . "'"
if ($strImage <> "") {
      $SQL = $SQL . ",'" . $strImage . "'"
}
      $SQL = $SQL . ") ");
}

Becomes:

      . ") "
      . "VALUES("
      . "'" . $strProviderservice . "',"
      . "'" . $strCompanyname . "',"
      . "'" . $strOwner . "',"
      . "'" . $strAddress . "',"
      . "'" . $strTown . "',"
      . "'" . $strZipcode . "',"
      . "'" . $strPhone . "',"
      . "'" . $str2ndphone . "',"
      . "'" . $strMobile . "',"
      . "'" . $strPager . "',"
      . "'" . $strFax . "',"
      . "'" . $strEmail . "',"
      . "'" . $strWebsite . "',"
      . "'" . $strLicense . "',"
      . "'" . $strBonded . "',"
      . "'" . $strHours . "',"
      . "'" . $str24houremerg . "',"
      . "'" . str_replace("'", "''", $strOtherservices) . "',"
      . "'" . $strServicearea . "',"
      . "'" . $strFreeestimate . "',"
      . "'" . $strWorkguaranteed . "',"
      . "'" . str_replace("'", "''", $strProvidertagline) . "',"
      . "'" . $strAd_size . "'"
if ($strImage <> "") {
      . ",'" . $strImage . "'"
}
      . ") ");
}
0
 
LVL 11

Assisted Solution

by:elfe69
elfe69 earned 100 total points
ID: 18771506
Your script is missing some ; beginning at "<html>" just before your else statement and then after all the lines where you construct $SQL after the else
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771518
I like the change you had me do, I can read a bit better now, but I'm still getting the same error on this line:

} else {  <---- This line
     $SQL = mysql_query("INSERT INTO tblAdspace VALUES"
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18771530
What is the error?
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18771543
Ah, I see it. Look two lines before the '} else {' line. You are missing a semicolon.

"</html>"

Should be:

"</html>";
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771565
Ok, thanks for that, but now all of a sudden the page went entirely blank.
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18771653
I think I am misunderstanding what you are trying to do with the following section:

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
"<head>\n";
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n";
"<title>Ask2bsure.com - (Admin Section) Edit Provider</title>\n";
"<link style=\"text/css\" href=\"/css/style.css\" rel=\"stylesheet\">\n";
"</head>\n";
"<body>\n";
"<table align=\"center\" id=\"admin\">\n";
"<tr><td align=\"center\" colspan=\"2\">\n";
"<img src=\"/images/sublogo_2.png\"><br />\n";
"<span style=\"font-size: 12px; color: #0000FF\">(Admin Section)</span>\n";
"</td></tr>\n";
"<tr><td valign=\"top\">\n";
"<div id=\"navlist\">\n";
"<a href=\"/admin/\">Home</a>\n";
"<a href=\"/admin/add_provider.php\">Add Provider</a>\n";
"<a href=\"/admin/list_providers.php?list=list\">Delete / Edit Provider</a>\n";
"<a href=\"/admin/list_providers.php?review=review\">Toggle / Edit Reviews</a>\n";
"<a href=\"/index.php\">Back To Website</a>\n";
"</div>\n";
"</td><td width=\"625\">\n";
"<table id=\"main_admin\" align=\"center\" border=\"0\">\n";
"<tr><td align=\"center\">\n";
"The selected provider has now been updated.\n";
"</td></tr>\n";
"</table>\n";
"</td></tr>\n";
"</table>\n";
"</body>\n";
"</html>";

It looks like you are trying to make each line an individual echo statement, in which case you need to add the word 'echo' before each line.

If, however, you want this to be one big echo statement, you need to remove the semicolon from after every line but the last, and add a perid in front of every line but the first.

0
 
LVL 24

Expert Comment

by:glcummins
ID: 18771654
"period" rather than "perid".
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771663
Do I keep the \n in front of each line?
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18771693
That is up to you. It will just make your HTML source look better if someone views it.
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18771705
You just echo the HTML header, every line beginning with " should begin with echo ".

Look at that:
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
"<head>\n";

It should be replaced by (add echo at beginning of each line):
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head>\n";

Or by (replace ; by , at end of each line except the last):

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n",
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n",
"<head>\n";
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771726
I was trying to make it into one entire echo statement, which it now displays after taking out the semicolons except for the last ones.  The problems now are 1) Nothing gets updated into the db 2) The page shows two rows of the same html table displaying "Your record has now been updated" even though nothing got updated.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771742
elfe69, is that a comma or a period at the end of each line?
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18771769
Should be a period. A comman will result in a parse error.
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18771790
a comma in my example, but a period would be ok too.

For your knowledge:

The difference between comma and period ?
- period is the string concatenation operator and all your strings will be concatenated before the echo command is processed
- comma is a separator supported by the echo command to echo multiple strings from one line, it has the advantage to avoid costly string concatenation as each string is echoed independently.

echo "string1", "string2", "string3";
is equivalent to
echo "string1";
echo "string2";
echo "string3";
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18771807
glcummins: you are wrong, comma will not result in a parse error and should be preferred as it avoids string concatenation.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18771962
Ok, thanks for the info, I will remember that in future coding.  Now back to my problem at hand, 1) Nothing gets updated into the db 2) The page shows two rows of the same html table displaying "Your record has now been updated" even though nothing got updated.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18772035
Ok, I fixed the double table, but the record is still not being updated.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18772050
Do you think it has anything do with...

$SQL = mysql_query("SELECT * FROM tblAdspace where strCompanyname = '" .$strCompanyname. "'");

if ($row = mysql_fetch_array($SQL)) {  <---- This line?

$SQL = mysql_query("UPDATE tblAdspace SET "
       . "strProviderservice = '" . $strProviderservice . "', "
     . "strCompanyname='" . $strCompanyname . "', "
     . "strOwner='" . $strOwner . "', "
       . "strAddress='" . $strAddress . "', "
     . "strTown='" . $strTown . "', "
       . "strZipcode='" . $strZipcode . "', "
       . "strPhone='" . $strPhone . "', "
     . "str2ndphone='" . $str2ndphone . "', "
     . "strMobile='" . $strMobile . "', "
     . "strPager='" . $strPager . "', "
     . "strFax='" . $strFax . "', "
     . "strEmail='" . $strEmail . "', "
     . "strWebsite='" . $strWebsite . "', "
     . "strLicense='" . $strLicense . "', "
     . "strInsured='" . $strInsured . "', "
     . "strBonded='" . $strBonded . "', "
     . "strHours='" . $strHours . "', "
     . "str24houremerg='" . $str24houremerg . "', "
     . "strOtherServices='" . str_replace(str_replace("'","''", $strOtherservices), "vbcrlf", "<br>") . "', "
     . "strServicearea='" . $strServicearea . "', "
     . "strInbusiness_since='" . $strInbusiness_since . "', "
     . " strServicesOffered='" . str_replace(str_replace("'","''", $strServicesoffered), "vbcrlf", "<br>") . "', "
       . "strFreeestimate='" . $strFreeestimate . "', "
     . "strWorkguaranteed='" . $strWorkguaranteed . "', "
       . "strProvidertagline='" . str_replace(str_replace("'", "''", $strProvidertagline), "vbcrlf", "<br>") . "', "
     . "strAd_size='" . $strAd_size . "'"
     . " WHERE strCompanyname = '" . strCompanyname . "'");
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18772075
Add the end of each mysql_* function, add:

or die (mysql_error());

This will report any error that occurs during the execution of the function.

For example,

$SQL = mysql_query("INSERT....") or die(mysql_error());

and

mysql_select_db('your_db') or die(mysql_error());

This will help during the troubleshooting process. As your code stands now, any mysql errors will fail silently.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18772123
Ok, I added those at the end of each like you said, but I'm am not getting any error messages being displayed.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18772157
Is there an easy way of displaying what the sql statement is doing?  Like echo $SQL; ?
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18772227
Yes, you can execute echo $SQL; to see your statement
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18772372
You know, I tried that, but all I get is:

Resource id #5
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18772418
Put your UPDATE statement string into a variable before executing it, so you will be able to echo the statement that you execute.
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18772446
Do it this way:

$mySqlStatement = "UPDATE tblAdspace SET "
       . "strProviderservice = '" . $strProviderservice . "', "
     . "strCompanyname='" . $strCompanyname . "', "
     . "strOwner='" . $strOwner . "', "
       . "strAddress='" . $strAddress . "', "
     . "strTown='" . $strTown . "', "
       . "strZipcode='" . $strZipcode . "', "
       . "strPhone='" . $strPhone . "', "
     . "str2ndphone='" . $str2ndphone . "', "
     . "strMobile='" . $strMobile . "', "
     . "strPager='" . $strPager . "', "
     . "strFax='" . $strFax . "', "
     . "strEmail='" . $strEmail . "', "
     . "strWebsite='" . $strWebsite . "', "
     . "strLicense='" . $strLicense . "', "
     . "strInsured='" . $strInsured . "', "
     . "strBonded='" . $strBonded . "', "
     . "strHours='" . $strHours . "', "
     . "str24houremerg='" . $str24houremerg . "', "
     . "strOtherServices='" . str_replace(str_replace("'","''", $strOtherservices), "vbcrlf", "<br>") . "', "
     . "strServicearea='" . $strServicearea . "', "
     . "strInbusiness_since='" . $strInbusiness_since . "', "
     . " strServicesOffered='" . str_replace(str_replace("'","''", $strServicesoffered), "vbcrlf", "<br>") . "', "
       . "strFreeestimate='" . $strFreeestimate . "', "
     . "strWorkguaranteed='" . $strWorkguaranteed . "', "
       . "strProvidertagline='" . str_replace(str_replace("'", "''", $strProvidertagline), "vbcrlf", "<br>") . "', "
     . "strAd_size='" . $strAd_size . "'"
     . " WHERE strCompanyname = '" . strCompanyname . "'");

echo $mySqlStatement;
$SQL = mysql_query($mySqlStatement) or die(mysql_error());
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18772496
Gotcha.

Maybe there is something wrong with this line on the form page?

<?= str_replace("<br>", "vbCrLf", Trim($strServicesoffered)) ?>
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ajax and PHP 4 47
Wordpress - Adding an if/else Conditional Argument in a Post Template 4 39
Survey branching tutorial 11 44
MySQL-Design Help 12 44
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question