Re: [PHP] Re: Error Querying Database
"Steve Staples" wrote in message news:1292447844.5460.16.ca...@webdev01... > On Wed, 2010-12-15 at 15:41 -0500, Gary wrote: >> ""Gary"" wrote in message >> news:81.d1.49824.33c09...@pb1.pair.com... >> >I cant seem to get this to connect. This is to my local testing server, >> >which is on, so we need not worry that I have posted the UN/PW. >> > >> > This is a duplicate of a script I have used countless times and it >> > worked. >> > The error message is 'Error querying database.' >> > >> > Some one point out the error of my ways? >> > >> > Gary >> > >> > >> > " method="post"> >> > >> > >> > Name of Beer> > /> >> > >> > >> > >> > >> > Maker of Beer >> > >> > >> > >> > >> > Type of Beer >> > >> > Imported >> > Domestic >> > Craft >> > Light >> > >> > >> > >> > >> > >> > Sold in >> > >> > Singles> > /> >> > Six Packs >> > Cans >> > Bottles >> > Draft >> > >> > >> > Size >> > >> > >> > Description> > rows="5"> >> > >> > >> > >> > >> > >> > >> > >> > > > $beername = $_POST['beername']; >> > $manu = $_POST['manu']; >> > $type = $_POST['type']; >> > $singles = $_POST['singles']; >> > $six = $_POST['six']; >> > $can = $_POST['can']; >> > $bottles = $_POST['bottles']; >> > $tap = $_POST['tap']; >> > $size = $_POST['size']; >> > $desc = $_POST['desc']; >> > $ip= $_SERVER['REMOTE_ADDR']; >> > >> > $dbc = mysqli_connect('localhost','root','','rr')or die('Error >> > connecting >> > with MySQL Database'); >> > >> > $query = "INSERT INTO beer (beername, manu, type, singles, six, can, >> > bottles, tap, size, desc, ip )"." VALUES ('$beername', '$manu', >> > '$type', >> > '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', >> > '$ip' )"; >> > >> > $result = mysqli_query($dbc, $query) >> > or die('Error querying database.'); >> > >> > >> > mysqli_close($dbc); >> > >> >> >> >> I have tried something completely different, changed to mysql instead of >> mysqli and I put it up on my remote server/database, and it is still not >> behaving... >> >> mysql_connect('server','un','pw') or die(mysql_error()); >> mysql_select_db("db") or die(mysql_error()); >> >> mysql_query("INSERT INTO beer (beername, manu, type, singles, six, can, >> bottles, tap, size, desc, ip)"."VALUES "."('$beername', '$manu', '$type', >> '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', >> '$ip' )") >> or die(mysql_error()); >> >> echo "Data Inserted!"; >> >> I am now getting this error message, but it does not make sense >> >> 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 'desc, >> ip)VALUES >> ('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1 >> >> Does this mean I am getting closer to getting some actual work done >> today? >> >> Thanks again >> >> gary > > > not sure if this is the issue or not, but you have reserved words in > your field names... try escaping them all in backticks... and the way i > do things with variables inside "", i put them in {}... here is what i > mean: > > mysql_query("INSERT INTO `beer` (`beername`, `manu`, `type`, `singles`, > `six`, `can`, `bottles`, `tap`, `size`, `desc`, `ip`)"."VALUES > "."('{$beername}', '{$manu}', '{$type}', '{$singles}', '{$six}', > '{$can}', '{$bottles}', '{$tap}', '{$size}', '{$desc', '{$ip}')"); > > Steve > > Steve Thanks again, that was the issue...let me throw that into my vault of knowledge about mysql (seems there is plenty of open space in there anyway) Thanks again Gary __ Information from ESET Smart Security, version of virus signature database 5706 (20101215) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Error Querying Database
"Bastien Koert" wrote in message news:aanlktik8s8rgeatp_aq=qjbbuebq9y13zrnhoq+rb...@mail.gmail.com... On Wed, Dec 15, 2010 at 3:41 PM, Gary wrote: > > ""Gary"" wrote in message > news:81.d1.49824.33c09...@pb1.pair.com... >>I cant seem to get this to connect. This is to my local testing server, >>which is on, so we need not worry that I have posted the UN/PW. >> >> This is a duplicate of a script I have used countless times and it >> worked. >> The error message is 'Error querying database.' >> >> Some one point out the error of my ways? >> >> Gary >> >> >> " method="post"> >> >> >> Name of Beer >> >> >> >> >> Maker of Beer >> >> >> >> >> Type of Beer >> >> Imported >> Domestic >> Craft >> Light >> >> >> >> >> >> Sold in >> Singles> /> >> Six Packs >> Cans >> Bottles >> Draft >> >> >> Size >> >> >> Description> rows="5"> >> >> >> >> >> >> >> >> > $beername = $_POST['beername']; >> $manu = $_POST['manu']; >> $type = $_POST['type']; >> $singles = $_POST['singles']; >> $six = $_POST['six']; >> $can = $_POST['can']; >> $bottles = $_POST['bottles']; >> $tap = $_POST['tap']; >> $size = $_POST['size']; >> $desc = $_POST['desc']; >> $ip= $_SERVER['REMOTE_ADDR']; >> >> $dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting >> with MySQL Database'); >> >> $query = "INSERT INTO beer (beername, manu, type, singles, six, can, >> bottles, tap, size, desc, ip )"." VALUES ('$beername', '$manu', '$type', >> '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', >> '$ip' )"; >> >> $result = mysqli_query($dbc, $query) >> or die('Error querying database.'); >> >> >> mysqli_close($dbc); >> > > > > I have tried something completely different, changed to mysql instead of > mysqli and I put it up on my remote server/database, and it is still not > behaving... > > mysql_connect('server','un','pw') or die(mysql_error()); > mysql_select_db("db") or die(mysql_error()); > > mysql_query("INSERT INTO beer (beername, manu, type, singles, six, can, > bottles, tap, size, desc, ip)"."VALUES "."('$beername', '$manu', '$type', > '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', > '$ip' )") > or die(mysql_error()); > > echo "Data Inserted!"; > > I am now getting this error message, but it does not make sense > > 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 'desc, > ip)VALUES > ('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1 > > Does this mean I am getting closer to getting some actual work done today? > > Thanks again > > gary > > > > __ Information from ESET Smart Security, version of virus > signature database 5706 (20101215) __ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > DESC is a reserved word in mysql ( http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html ) Either change the field name or enclose the statement in backticks to prevent this error. Changing the field name is my recommended action -- Bastien Cat, the other other white meat And she appears.viola! That was itthank you for your help... I think this will require some onsite research at this site owners shop... Thanks again Gary __ Information from ESET Smart Security, version of virus signature database 5706 (20101215) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Error Querying Database
On Wed, 2010-12-15 at 15:41 -0500, Gary wrote: > ""Gary"" wrote in message > news:81.d1.49824.33c09...@pb1.pair.com... > >I cant seem to get this to connect. This is to my local testing server, > >which is on, so we need not worry that I have posted the UN/PW. > > > > This is a duplicate of a script I have used countless times and it worked. > > The error message is 'Error querying database.' > > > > Some one point out the error of my ways? > > > > Gary > > > > > > " method="post"> > > > > > > Name of Beer > > > > > > > > > > Maker of Beer > > > > > > > > > > Type of Beer > > > > Imported > > Domestic > > Craft > > Light > > > > > > > > > > > > Sold in > > Singles > /> > > Six Packs > > Cans > > Bottles > > Draft > > > > > > Size > > > > > > Description > rows="5"> > > > > > > > > > > > > > > > > > $beername = $_POST['beername']; > > $manu = $_POST['manu']; > > $type = $_POST['type']; > > $singles = $_POST['singles']; > > $six = $_POST['six']; > > $can = $_POST['can']; > > $bottles = $_POST['bottles']; > > $tap = $_POST['tap']; > > $size = $_POST['size']; > > $desc = $_POST['desc']; > > $ip= $_SERVER['REMOTE_ADDR']; > > > > $dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting > > with MySQL Database'); > > > > $query = "INSERT INTO beer (beername, manu, type, singles, six, can, > > bottles, tap, size, desc, ip )"." VALUES ('$beername', '$manu', '$type', > > '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', > > '$ip' )"; > > > > $result = mysqli_query($dbc, $query) > > or die('Error querying database.'); > > > > > > mysqli_close($dbc); > > > > > > I have tried something completely different, changed to mysql instead of > mysqli and I put it up on my remote server/database, and it is still not > behaving... > > mysql_connect('server','un','pw') or die(mysql_error()); > mysql_select_db("db") or die(mysql_error()); > > mysql_query("INSERT INTO beer (beername, manu, type, singles, six, can, > bottles, tap, size, desc, ip)"."VALUES "."('$beername', '$manu', '$type', > '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', '$ip' )") > or die(mysql_error()); > > echo "Data Inserted!"; > > I am now getting this error message, but it does not make sense > > 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 'desc, ip)VALUES > ('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1 > > Does this mean I am getting closer to getting some actual work done today? > > Thanks again > > gary not sure if this is the issue or not, but you have reserved words in your field names... try escaping them all in backticks... and the way i do things with variables inside "", i put them in {}... here is what i mean: mysql_query("INSERT INTO `beer` (`beername`, `manu`, `type`, `singles`, `six`, `can`, `bottles`, `tap`, `size`, `desc`, `ip`)"."VALUES "."('{$beername}', '{$manu}', '{$type}', '{$singles}', '{$six}', '{$can}', '{$bottles}', '{$tap}', '{$size}', '{$desc', '{$ip}')"); Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Error Querying Database
On Wed, Dec 15, 2010 at 3:41 PM, Gary wrote: > > ""Gary"" wrote in message > news:81.d1.49824.33c09...@pb1.pair.com... >>I cant seem to get this to connect. This is to my local testing server, >>which is on, so we need not worry that I have posted the UN/PW. >> >> This is a duplicate of a script I have used countless times and it worked. >> The error message is 'Error querying database.' >> >> Some one point out the error of my ways? >> >> Gary >> >> >> " method="post"> >> >> >> Name of Beer >> >> >> >> >> Maker of Beer >> >> >> >> >> Type of Beer >> >> Imported >> Domestic >> Craft >> Light >> >> >> >> >> >> Sold in >> Singles> /> >> Six Packs >> Cans >> Bottles >> Draft >> >> >> Size >> >> >> Description> rows="5"> >> >> >> >> >> >> >> >> > $beername = $_POST['beername']; >> $manu = $_POST['manu']; >> $type = $_POST['type']; >> $singles = $_POST['singles']; >> $six = $_POST['six']; >> $can = $_POST['can']; >> $bottles = $_POST['bottles']; >> $tap = $_POST['tap']; >> $size = $_POST['size']; >> $desc = $_POST['desc']; >> $ip= $_SERVER['REMOTE_ADDR']; >> >> $dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting >> with MySQL Database'); >> >> $query = "INSERT INTO beer (beername, manu, type, singles, six, can, >> bottles, tap, size, desc, ip )"." VALUES ('$beername', '$manu', '$type', >> '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', >> '$ip' )"; >> >> $result = mysqli_query($dbc, $query) >> or die('Error querying database.'); >> >> >> mysqli_close($dbc); >> > > > > I have tried something completely different, changed to mysql instead of > mysqli and I put it up on my remote server/database, and it is still not > behaving... > > mysql_connect('server','un','pw') or die(mysql_error()); > mysql_select_db("db") or die(mysql_error()); > > mysql_query("INSERT INTO beer (beername, manu, type, singles, six, can, > bottles, tap, size, desc, ip)"."VALUES "."('$beername', '$manu', '$type', > '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', '$ip' )") > or die(mysql_error()); > > echo "Data Inserted!"; > > I am now getting this error message, but it does not make sense > > 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 'desc, ip)VALUES > ('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1 > > Does this mean I am getting closer to getting some actual work done today? > > Thanks again > > gary > > > > __ Information from ESET Smart Security, version of virus signature > database 5706 (20101215) __ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > DESC is a reserved word in mysql ( http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html ) Either change the field name or enclose the statement in backticks to prevent this error. Changing the field name is my recommended action -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Error Querying Database
""Gary"" wrote in message news:81.d1.49824.33c09...@pb1.pair.com... >I cant seem to get this to connect. This is to my local testing server, >which is on, so we need not worry that I have posted the UN/PW. > > This is a duplicate of a script I have used countless times and it worked. > The error message is 'Error querying database.' > > Some one point out the error of my ways? > > Gary > > > " method="post"> > > > Name of Beer > > > > > Maker of Beer > > > > > Type of Beer > > Imported > Domestic > Craft > Light > > > > > > Sold in > Singles /> > Six Packs > Cans > Bottles > Draft > > > Size > > > Description rows="5"> > > > > > > > > $beername = $_POST['beername']; > $manu = $_POST['manu']; > $type = $_POST['type']; > $singles = $_POST['singles']; > $six = $_POST['six']; > $can = $_POST['can']; > $bottles = $_POST['bottles']; > $tap = $_POST['tap']; > $size = $_POST['size']; > $desc = $_POST['desc']; > $ip= $_SERVER['REMOTE_ADDR']; > > $dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting > with MySQL Database'); > > $query = "INSERT INTO beer (beername, manu, type, singles, six, can, > bottles, tap, size, desc, ip )"." VALUES ('$beername', '$manu', '$type', > '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', > '$ip' )"; > > $result = mysqli_query($dbc, $query) > or die('Error querying database.'); > > > mysqli_close($dbc); > I have tried something completely different, changed to mysql instead of mysqli and I put it up on my remote server/database, and it is still not behaving... mysql_connect('server','un','pw') or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); mysql_query("INSERT INTO beer (beername, manu, type, singles, six, can, bottles, tap, size, desc, ip)"."VALUES "."('$beername', '$manu', '$type', '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', '$ip' )") or die(mysql_error()); echo "Data Inserted!"; I am now getting this error message, but it does not make sense 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 'desc, ip)VALUES ('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1 Does this mean I am getting closer to getting some actual work done today? Thanks again gary __ Information from ESET Smart Security, version of virus signature database 5706 (20101215) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php