Jump to content

SQL Query should work but doesn't.


Renegade605

Recommended Posts

Hi all, I'm trying to use a PHP interface to enter a set of information into a user database. This is the code I'm using:

<?php	$mysql_data = mysql_fetch_assoc(mysql_query("SELECT * FROM pendingrecruits WHERE record_ID = " . $id));	/* Retrieve the information submitted in the application. */	mysql_query("INSERT INTO names (Name) VALUES ('" . $mysql_data['Name'] . "')");	$mysql_data2 = mysql_fetch_assoc(mysql_query("SELECT member_ID FROM names WHERE Name = '" . $mysql_data['Name'] . "'"));	/* The 'member_ID' field is set to auto_increment. Add the name to the list and retrieve the new ID assigned to the user. */	$mid = $mysql_data2['member_ID'];		if (!mysql_query("INSERT INTO contacts 					VALUES (" . $mid . ", '" . $mysql_data['Email'] . "', '" . $mysql_data['XFire'] . "');	INSERT INTO logintimes (member_ID) VALUES (" . $mid . ");	INSERT INTO medals (member_ID) VALUES (" . $mid . ");	INSERT INTO notepads (member_ID) VALUES (" . $mid . ");	INSERT INTO profile (member_ID) VALUES (" . $mid . ");	INSERT INTO ranks VALUES (" . $mid . ", 'CDT');	INSERT INTO recruitment (member_ID, DateRecruited) VALUES (" . $mid . ", NOW());	INSERT INTO ribbons (member_ID) VALUES (" . $mid . ")"))	{		mysql_query("DELETE FROM names WHERE member_ID = " . $mid); /* Clean up the 'Name' entry if the others don't show up. */	?>		<span class="error">UNSUCCESSFUL</span> <!-- <?=mysql_error()?> --></li>	<?php	}	else	{		mysql_query("DELETE FROM pendingrecruits WHERE record_ID = " . $id); /* Remove the application. */	?>		<span style="color: #719537;">SUCCESSFUL</span></li>	<?php	}?>

At first the mysql_error() function within the HTML comment tags returned a syntax error, which I fixed. After I fixed that, the PHP code still reports unsuccessful, but the mysql_error() function does not return anything. I've tried plugging the main query directly into the SQL server (through PHPMyAdmin) and the query executes without error. Why does sending the query through PHP return an error when the query is valid?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...