Qbasicnews.com

Full Version: PHP + MySQL problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm making a site for my dad's company, and I'm suuuuuper close to being finished, but I can't get this query to work. I have the table created in the database, and it seems to be formatted properly, so I hope it isn't size that's a problem.

Please try to pinpoint my mistake:
Code:
$query = "INSERT INTO `on_entries`(`university`,`name1`,`name1_major`,`name1_degree`,";
$query .= "`name2`,`name2_major`,`name2_degree`,`name3`,`name3_major`,`name3_degree`,";
$query .= "`name4`,`name4_major`,`name4_degree`,`name5`,`name5_major`,`name5_degree`,";
$query .= "`name6`,`name6_major`,`name6_degree`,`team_contact_name`,`team_contact_address`,";
$query .= "`team_contact_phone`,`team_contact_email`,`faculty_contact_name`,";
$query .= "`faculty_contact_address`,`faculty_contact_phone`,`faculty_contact_email`,";
$query .= "`faculty_contact_title`,`tech_area1`,`tech_area2`,`tech_area3`,`tech_area4`,";
$query .= "`tech_area5`,`tech_area6`,`tech_area7`,`tech_area8`) ";
$query .= "VALUES('".addslashes($_POST['university'])."', '". addslashes($_POST['name1'])."', '";
$query .= addslashes($_POST['name1_major'])."', '".addslashes($_POST['name1_degree'])."', '";
$query .= addslashes($_POST['name2'])."', '".addslashes($_POST['name2_major'])."', '";
$query .= addslashes($_POST['name2_degree'])."', '". addslashes($_POST['name3'])."', '";
$query .= addslashes($_POST['name3_major'])."', '".addslashes($_POST['name3_degree'])."', '";
$query .= addslashes($_POST['name4'])."', '".addslashes($_POST['name4_major'])."', '";
$query .= addslashes($_POST['name4_degree'])."', '".addslashes($_POST['name5'])."', '";
$query .= addslashes($_POST['name5_major'])."', '".addslashes($_POST['name5_degree'])."', '";
$query .= addslashes($_POST['name6'])."', '".addslashes($_POST['name6_major'])."', '";
$query .= addslashes($_POST['name6_degree'])."', '".addslashes($_POST['team_contact_name'])."', '";
$query .= addslashes($_POST['team_contact_address'])."', '". addslashes($_POST['team_contact_phone'])."', '";
$query .= addslashes($_POST['team_contact_email'])."', '". addslashes($_POST['faculty_contact_name'])."', '";
$query .= addslashes($_POST['faculty_contact_address'])."', '".addslashes($_POST['faculty_contact_phone']);
$query .= "', '".addslashes($_POST['faculty_contact_email'])."', '";
$query .= addslashes($_POST['faculty_contact_title'])."', '".addslashes($_POST['tech_area1'])."', '";
$query .= addslashes($_POST['tech_area2'])."', '".addslashes($_POST['tech_area3'])."', '";
$query .= addslashes($_POST['tech_area4'])."', '".addslashes($_POST['tech_area5'])."', '";
$query .= addslashes($_POST['tech_area6'])."', '". addslashes($_POST['tech_area7'])."', '";
$query .= addslashes($_POST['tech_area8'])."');";
$result = mysql_query($query);

::EDIT::
I made it print out the query string, I put it into SQLyog, and it worked PERFECTLY! WTF?????
What error message did occurre??
....
Next time I see you online I will talk to you (AIM/ICQ/MSN)
I didn't have the mysql_query($query) or die ("Error :". mysql_error()); so I don't know.
Well... since you're using mysql_query... you don't need to put a semicolon at the end of your queries I believe. In fact I think somewhere in the PHP documentation it specifically says not to...

so...

Code:
$query .= addslashes($_POST['tech_area6'])."', '". addslashes($_POST['tech_area7'])."', '";
$query .= addslashes($_POST['tech_area8'])."');";
$result = mysql_query($query);

That's your original last three lines of code...
Just remove the semicolon from the second last line in the quotes at the end of the string. So basically, when you print out the entire query string there should be no semicolon at the end.

Hope that works Wink[/quote][/code]
No, that last line I typed in after pasting the query lines. In reality, I had
Code:
$result = mysql_query($result);
Ya, I know I'm an idiot.