pingeyeg
asked on
SQL is not retrieving the form data on certain fields.
Not sure why, but my sql statement is not retrieving what my form is sending out. I have triple checked to make sure the variables are correct. I'm not sure if it means anything, but the two that are not being retrieved are longtext strings in phpMyAdmin.
$strProviderservice = $_REQUEST['strProviderserv ice'];
$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_s ince'];
$strLicense = $_REQUEST['strLicense'];
$strInsured = $_REQUEST['strInsured'];
$strBonded = $_REQUEST['strBonded'];
$strHours = $_REQUEST['strHours'];
$str24houremerg = $_REQUEST['str24houremerg' ];
$strServicesoffered = $_REQUEST['strServicesoffe red'];
$strOtherservices = $_REQUEST['strOtherservice s'];
$strServicearea = $_REQUEST['strServicearea' ];
$strFreeestimate = $_REQUEST['strFreeestimate '];
$strWorkguaranteed = $_REQUEST['strWorkguarante ed'];
$strProvidertagline = $_REQUEST['strProvidertagl ine'];
$strAd_size = $_REQUEST['strAd_size'];
$SQL = "INSERT INTO tblAdspace VALUES"
. "("
. "strProviderservice, strCompanyname, strOwner, strAddress, strTown, "
. "strZipcode, strPhone, str2ndphone, "
. "strMobile, strPager, strFax, "
. "strEmail, strWebsite, strLicense, "
. "strBonded, strHours, str24houremerg, strServicesoffered, "
. "strOtherservices, strServicearea, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size"
. ") "
. "VALUES("
. "'" . $strProviderservice . "',"
. "'" . $strCompanyname . "',"
. "'" . $strOwner . "',"
. "'" . $strAddress . "',"
. "'" . $strTown . "',"
. "'" . $strZipcode . "',"
. "'" . $strPhone . "',"
. "'" . $str2ndphone . "',"
. "'" . $strMobile . "',"
. "'" . $strPager . "',"
. "'" . $strFax . "',"
. "'" . $strEmail . "',"
. "'" . $strWebsite . "',"
. "'" . $strLicense . "',"
. "'" . $strBonded . "',"
. "'" . $strHours . "',"
. "'" . $str24houremerg . "',"
. "'" . str_replace("'", "''", $strOtherservices) . "',"
. "'" . str_replace("'", "''", $strServicesoffered) . "', "
. "'" . $strServicearea . "',"
. "'" . $strFreeestimate . "',"
. "'" . $strWorkguaranteed . "',"
. "'" . str_replace("'", "''", $strProvidertagline) . "',"
. "'" . $strAd_size . "'"
. ") ";
echo $SQL;
die;
$strProviderservice = $_REQUEST['strProviderserv
$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_s
$strLicense = $_REQUEST['strLicense'];
$strInsured = $_REQUEST['strInsured'];
$strBonded = $_REQUEST['strBonded'];
$strHours = $_REQUEST['strHours'];
$str24houremerg = $_REQUEST['str24houremerg'
$strServicesoffered = $_REQUEST['strServicesoffe
$strOtherservices = $_REQUEST['strOtherservice
$strServicearea = $_REQUEST['strServicearea'
$strFreeestimate = $_REQUEST['strFreeestimate
$strWorkguaranteed = $_REQUEST['strWorkguarante
$strProvidertagline = $_REQUEST['strProvidertagl
$strAd_size = $_REQUEST['strAd_size'];
$SQL = "INSERT INTO tblAdspace VALUES"
. "("
. "strProviderservice, strCompanyname, strOwner, strAddress, strTown, "
. "strZipcode, strPhone, str2ndphone, "
. "strMobile, strPager, strFax, "
. "strEmail, strWebsite, strLicense, "
. "strBonded, strHours, str24houremerg, strServicesoffered, "
. "strOtherservices, strServicearea, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size"
. ") "
. "VALUES("
. "'" . $strProviderservice . "',"
. "'" . $strCompanyname . "',"
. "'" . $strOwner . "',"
. "'" . $strAddress . "',"
. "'" . $strTown . "',"
. "'" . $strZipcode . "',"
. "'" . $strPhone . "',"
. "'" . $str2ndphone . "',"
. "'" . $strMobile . "',"
. "'" . $strPager . "',"
. "'" . $strFax . "',"
. "'" . $strEmail . "',"
. "'" . $strWebsite . "',"
. "'" . $strLicense . "',"
. "'" . $strBonded . "',"
. "'" . $strHours . "',"
. "'" . $str24houremerg . "',"
. "'" . str_replace("'", "''", $strOtherservices) . "',"
. "'" . str_replace("'", "''", $strServicesoffered) . "', "
. "'" . $strServicearea . "',"
. "'" . $strFreeestimate . "',"
. "'" . $strWorkguaranteed . "',"
. "'" . str_replace("'", "''", $strProvidertagline) . "',"
. "'" . $strAd_size . "'"
. ") ";
echo $SQL;
die;
Have you tried changing the attribute type to VARCHAR() just to see if it is the data type that is causing an issue ?
Just out of curiosity, why are you concatinating all your attribute values into your DB ?
Just out of curiosity, why are you concatinating all your attribute values into your DB ?
try doing this:
<?
print "<pre>";
print $SQL;
print "</pre>";
?>
at the end of your page and see if the variables are being passed correctly.
if they aren't, try this:
before assigning variables that use the $_REQUEST variable, assign the $_REQUEST variable yourself like this:
$_REQUEST = ( isset($_REQEST) && !empty($_REQUEST) ) ? $_REQUEST : array_merge($_GET, $_POST);
<?
print "<pre>";
print $SQL;
print "</pre>";
?>
at the end of your page and see if the variables are being passed correctly.
if they aren't, try this:
before assigning variables that use the $_REQUEST variable, assign the $_REQUEST variable yourself like this:
$_REQUEST = ( isset($_REQEST) && !empty($_REQUEST) ) ? $_REQUEST : array_merge($_GET, $_POST);
with further studying of your code, i've noticed something else. your sql is formatted incorrectly, and the syntax is wrong (line 1, char 24-29). this should be correct now:
$SQL = "INSERT INTO tblAdspace
. "("
. "strProviderservice, strCompanyname, strOwner, strAddress, strTown, "
. "strZipcode, strPhone, str2ndphone, "
. "strMobile, strPager, strFax, "
. "strEmail, strWebsite, strLicense, "
. "strBonded, strHours, str24houremerg, strServicesoffered, "
. "strOtherservices, strServicearea, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size"
. ") "
. "VALUES("
. "'" . $strProviderservice . "',"
. "'" . $strCompanyname . "',"
. "'" . $strOwner . "',"
. "'" . $strAddress . "',"
. "'" . $strTown . "',"
. "'" . $strZipcode . "',"
. "'" . $strPhone . "',"
. "'" . $str2ndphone . "',"
. "'" . $strMobile . "',"
. "'" . $strPager . "',"
. "'" . $strFax . "',"
. "'" . $strEmail . "',"
. "'" . $strWebsite . "',"
. "'" . $strLicense . "',"
. "'" . $strBonded . "',"
. "'" . $strHours . "',"
. "'" . $str24houremerg . "',"
. "'" . str_replace("'", "''", $strOtherservices) . "',"
. "'" . str_replace("'", "''", $strServicesoffered) . "', "
. "'" . $strServicearea . "',"
. "'" . $strFreeestimate . "',"
. "'" . $strWorkguaranteed . "',"
. "'" . str_replace("'", "''", $strProvidertagline) . "',"
. "'" . $strAd_size . "'"
. ") ";
$SQL = "INSERT INTO tblAdspace
. "("
. "strProviderservice, strCompanyname, strOwner, strAddress, strTown, "
. "strZipcode, strPhone, str2ndphone, "
. "strMobile, strPager, strFax, "
. "strEmail, strWebsite, strLicense, "
. "strBonded, strHours, str24houremerg, strServicesoffered, "
. "strOtherservices, strServicearea, strFreeestimate, strWorkguaranteed, strProvidertagline, strAd_size"
. ") "
. "VALUES("
. "'" . $strProviderservice . "',"
. "'" . $strCompanyname . "',"
. "'" . $strOwner . "',"
. "'" . $strAddress . "',"
. "'" . $strTown . "',"
. "'" . $strZipcode . "',"
. "'" . $strPhone . "',"
. "'" . $str2ndphone . "',"
. "'" . $strMobile . "',"
. "'" . $strPager . "',"
. "'" . $strFax . "',"
. "'" . $strEmail . "',"
. "'" . $strWebsite . "',"
. "'" . $strLicense . "',"
. "'" . $strBonded . "',"
. "'" . $strHours . "',"
. "'" . $str24houremerg . "',"
. "'" . str_replace("'", "''", $strOtherservices) . "',"
. "'" . str_replace("'", "''", $strServicesoffered) . "', "
. "'" . $strServicearea . "',"
. "'" . $strFreeestimate . "',"
. "'" . $strWorkguaranteed . "',"
. "'" . str_replace("'", "''", $strProvidertagline) . "',"
. "'" . $strAd_size . "'"
. ") ";
ASKER
Oscurochu, with your code I am getting a parse error: Line . "("
ASKER
Ok, Oscurochu, I found what was missing in your code, but it still isn't working. I don't think the problem lies in the sql statement, I think the problem is in the $_REQUEST portion of the page, because most of the values are being brought in, only two aren't. The two that aren't are formatted in phpMyAdmin as Longtext.
ASKER
Tchuki, what do you mean by using the VARCHAR() ?
Why are you concatinating your vars into the DB ?
What are the column attribute names in your tblAdspace ?
What are the column attribute names in your tblAdspace ?
ASKER
I was told it would be easier to read the code towards troubleshooting.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried making an update with field that is a regular text value and it works, but the two that are longtext aren't working.
Have you tried changing the fields to VARCHAR and seeing if any information is inserted ?!
ASKER
Can you show me how to do that? I don't know what VARCHAR is.
Go into phpMyAdmin, select your table and change the field type in there.
ASKER
Ok, just out of curiosity, what would you change it to if the field needs to have 300 characters in it?
longtext should be the one you go for.
That said, try what I have suggested and see if the information is inserted.
We need to assertain if it is your PHP $_POST vars, SQL statement or DB itself that is having the issue.
That said, try what I have suggested and see if the information is inserted.
We need to assertain if it is your PHP $_POST vars, SQL statement or DB itself that is having the issue.
ASKER
RIght now the field type is already longtext for those two fields.
Yes, try changing it to VARCHAR and see if any information is collected that way ...
ASKER
That didn't do the trick.
OK, which are the two fields that are not being inserted, what are their names ?
ASKER
strServicesoffered and strOtherservices
Does strProvidertagline insert correctly ?
ASKER
Apparently it does not. Huh.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still nothing. What was that supposed to do anyway?
ASKER
Isn't that funtion supposed to work like that? When people add text to these boxes they will most certainly be using apostrophes on certain word. How will he addslashes function change that?
ASKER
Nevermind, that did work. I saw one other thing that I had extra that was conflicting with your statement. It now works. I don't know why, but now all of a sudden I can't change anything in phpMyAdmin without it kicking me out again.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Woops
echo $str; // output: This string\'s been escaped
Should be:
echo $str; // output: This strings\' been escaped
Also with regards to you being kicked from phpMyAdmin, you probably need to refresh your cookie or something. Try logging out, closing the browser completely and then going back to phpMyAdmin.
echo $str; // output: This string\'s been escaped
Should be:
echo $str; // output: This strings\' been escaped
Also with regards to you being kicked from phpMyAdmin, you probably need to refresh your cookie or something. Try logging out, closing the browser completely and then going back to phpMyAdmin.
ASKER