...

View Full Version : Won't Delete Row



dniwebdesign
04-06-2004, 07:35 AM
$gametype=$_POST["gametype"];
$gamenumber=$_POST["gamenumber"];
$result1=mysql_query("DELETE FROM hockeystats_gs_headers WHERE gamenumber='$gamenumber' and gametype='$gametype'",$connection) or print mysql_error();
$result2=mysql_query("DELETE FROM hockeystats_gs_shots WHERE gamenumber='$gamenumber' and gametype='$gametype'",$connection) or print mysql_error();
$result3=mysql_query("DELETE FROM hockeystats_gs_roster WHERE gamenumber='$gamenumber' and gametype='$gametype'",$connection) or print mysql_error();
$result4=mysql_query("DELETE FROM hockeystats_gs_goals WHERE gamenumber='$gamenumber' and gametype='$gametype'",$connection) or print mysql_error();
$result5=mysql_query("DELETE FROM hockeystats_gs_penalties WHERE gamenumber='$gamenumber' and gametype='$gametype'",$connection) or print mysql_error();
if ($result5)
{
echo "<p class=\"bodymd\"><font face=Arial size=2>The gamesheet has been removed from the database.</font></p>";
}
else
{
echo "<p> <font face=Arial size=2><p class=\"bodylgbold\">Error Removing Player</p></font>";
}

I have this code and it won't delete the row from the table. Is there something wrong with it because if there is, I don't see it. :confused:

bcarl314
04-06-2004, 01:41 PM
A quick question, you have the mysql_error() printing out, what does it say?

Second, in your if statement, shouldn't that be:



if($result1 && $result2 && $result3 && $result4 && $result5) {


to make sure all the statments executed?

dniwebdesign
04-06-2004, 03:29 PM
My error doesn't do anything. It seems to execute just fine (even when I had that if statement you told to include) however the row is still in my database after I executed it.

bcarl314
04-06-2004, 03:40 PM
Debuggin hints:

1) try running the SQL statements from the command line. Do they work then?

2) Are the columns your using in the where clause varchar, char, or text? If not, drop the single quotes around your variables

3) Run the mysql_affected_rows() (http://www.php.net/manual/en/function.mysql-affected-rows.php) command after executing each query.

dniwebdesign
04-07-2004, 05:01 AM
"mysql_affected_rows()" doesn't seem to print anything...

dniwebdesign
04-07-2004, 05:47 AM
Nevermind, found out the problem. Left out something in my form I use to submit the data.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum