It is currently Tue Jan 23, 2018 11:41 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Weird error
PostPosted: Mon Jun 18, 2007 12:30 pm 
Noobie
Noobie

Joined: Mon Jun 18, 2007 12:28 pm
Posts: 5
Error: 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 'group ) values('A', 'A', 'A')' at line 1

Hmmmm?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 1:35 pm 
Noobie
Noobie

Joined: Wed Jun 06, 2007 2:37 pm
Posts: 17
Sounds to me like your command was incorrect, but no one can really give you any advice unless you give us the command that you were trying to use.

If you need to replace values with value, that's fine, but sometimes it's as simple as a missing quote or parenthesis.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 8:43 pm 
Noobie
Noobie

Joined: Mon Jun 18, 2007 12:28 pm
Posts: 5
I'll post the code, most of it is from a guide I was using because it's been a really long time since I've messed with php and I've forgotten most of it but here's the code.

Quote:
<html>
<head>
</head>
<body>
<?php
if ( isset( $title ) && isset( $size ) && isset( $group ) )
{
// check user input here!
$dberror = "";
$ret = add_to_database( $title, $size, $group, $dberror );
if ( ! $ret )
print "Error: $dberror<BR>";
else
print "Thank you very much";
}
else {
write_form();
}

function add_to_database( $title, $size, $group, &$dberror )
{
$user = "nicpow1_collect";
$pass = "********";
$db = "nicpow1_collect";
$link = mysql_pconnect( "mysql1.100ws.com", $user, $pass );
if ( ! $link )
{
$dberror = "Couldn't connect to MySQL server";
return false;
}
if ( ! mysql_select_db( $db, $link ) )
{
$dberror = mysql_error();
return false;
}
$query = "INSERT INTO soccer ( title, size, group ) values('$title', '$size', '$group')";
if ( ! mysql_query( $query, $link ) )
{
$dberror = mysql_error();
return false;
}
return true;
}

function write_form()
{
global $PHP_SELF;
print "<form action=\"$PHP_SELF\" method=\"POST\">\n";
print "<input type=\"text\" name=\"title\"> ";
print "Title<p>\n";
print "<input TYPE=\"text\" name=\"size\"> ";
print "Size<p>\n";
print "<select name=\"group\">\n";
print "\t<option value=\"A\"> Group A\n";
print "\t<option value=\"B\"> Group B\n";
print "</select>\n";
print "<input type=\"submit\" value=\"submit!\">\n</form>\n";
}
?>
</body>
</html>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 10:11 pm 
Noobie
Noobie

Joined: Wed Jun 06, 2007 2:37 pm
Posts: 17
The only thing I can see that I'm unsure about (I'm kind of a noob, but I thought I'd see if I could find something that jumped out at me) is this:

Code:
function add_to_database( $title, $size, $group, &$dberror )


Should there be a & there?

Also, is it possible that the values of your variables already have quotes around them so you're in fact adding double quotes?

Sorry I'm not much help. Maybe some day.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 10:35 pm 
Noobie
Noobie

Joined: Mon Jun 18, 2007 12:28 pm
Posts: 5
I tried removing the & and all that did was make it say the word "Error" only when I tried to submit data. Then I tried removing the quotes on the values and I get the same error as before with the wrong syntax or whatever.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2007 7:01 pm 
Noobie
Noobie

Joined: Mon Jun 18, 2007 12:28 pm
Posts: 5
Issue has been resolved. Turns out the word "group" is a reserved word in MySQL so it interfered with my code. Got it fixed, thanks anyway for the help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2007 7:29 pm 
Noobie
Noobie

Joined: Wed Jun 06, 2007 2:37 pm
Posts: 17
Sorry I couldn't help, but thanks for posting the resolution so that I can keep that in mind next time. :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2007 7:43 am 
Noobie
Noobie

Joined: Mon Jun 18, 2007 12:28 pm
Posts: 5
Np Jengri, thanks for trying. And thanks for the info Psychotic, will come in handy in the future.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ]  Moderators: fhmagic, KJ, Support Team, Moderators

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011