Solved

Getting parse error in sql statement

Posted on 2007-03-22
31
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 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