coutts Posted March 5, 2009 Share Posted March 5, 2009 I have the following 2 pages. The user enters the SKU number in the form on delete.htm adn the pic file and SQL database entry are deleted in delete.php. Only they arent. Delete.php is a blank page (no errors), and as you can see I echoed SKU and I dont think it is being passed. Any help, thanks This is delete.htm <html> <head> <title>Delete Item</title> <style> td {font-family:arial; font-weight:500; font-size:12px; color:black} </style> </head> <body> <center> <form action="delete.php" method="post" name="addform"> <table align="center" border="1" bgcolor="white" frame="box" bordercolor="black" bordercolorlight="black" bordercolordark="black" cellspacing="0" cellpadding="25" width="640"> <td valign="top"> <table border="0"> <tr><td>SKU</td><td><input type="text" name="SKU" size="15"></td></tr> </table> <input type="submit" value="Delete Item"> </form> </table> </td></table> </center> </body> </html> This is delete.php <html> <head> <title>Delete Item</title></head> <body bgcolor="#FFFFFF"> <?php $sku = $_POST["SKU"]; echo( $sku ); #connect to MySQL $conn=@mysql_connect( "localhost", "", "") or die( "Err:Conn" ); #select the specified database $rs = @mysql_select_db( "tractors", $conn ) or die( "Err:Db" ); #create the query $sql = "select SKU, TITLE, DESCRIPTION, PRICE, CATEGORY from tractors" #execute the query $rs = mysql_query( $sql, $conn ); #write the data while( $row = mysql_fetch_array( $rs ) ) { $sql = "DELETE FROM tractors WHERE SKU=$sku"; $pics = "../pics/" . $row["SKU"] . ".jpg"; unlink( $pics ); $result = mysql_query($sql); echo( "<br><br><br><br><table align='center' border='3' bgcolor='white' frame='box' bordercolor='black' bordercolorlight='black' bordercolordark='black' cellspacing='0' cellpadding='10'><td>" ); echo( "<font face='arial' color='black' size='3'>Item " . $row["SKU"] . " has been deleted."); echo( "</td></table>" ); mysql_close($sql); } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/148132-solved-would-someone-check-this-code-please/ Share on other sites More sharing options...
revraz Posted March 5, 2009 Share Posted March 5, 2009 Turn on error display and error reporting Echo your $sql to make sure it's valid Use mysql_error after your query to see if there are any errors Remove your mysql_close($sql) at the end of your while loop Link to comment https://forums.phpfreaks.com/topic/148132-solved-would-someone-check-this-code-please/#findComment-777589 Share on other sites More sharing options...
coutts Posted March 5, 2009 Author Share Posted March 5, 2009 Tried all suggestions without any clue. Still getting a blank window <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD> <BODY></BODY></HTML> Link to comment https://forums.phpfreaks.com/topic/148132-solved-would-someone-check-this-code-please/#findComment-777597 Share on other sites More sharing options...
revraz Posted March 5, 2009 Share Posted March 5, 2009 Repost the code with the changes. So you are saying no errors are reported? The only way you would get a blank screen and if there are no errors is if $_POST['SKU'] is empty. Link to comment https://forums.phpfreaks.com/topic/148132-solved-would-someone-check-this-code-please/#findComment-777601 Share on other sites More sharing options...
coutts Posted March 5, 2009 Author Share Posted March 5, 2009 I found the problem (and its one of those duh problems) the ; on the end of #create the query $sql = "select SKU, TITLE, DESCRIPTION, PRICE, CATEGORY from tractors"; was missing. New to PHP - used to programming with visual basic - no need to end lines with vb. Thanks for help Link to comment https://forums.phpfreaks.com/topic/148132-solved-would-someone-check-this-code-please/#findComment-777612 Share on other sites More sharing options...
revraz Posted March 5, 2009 Share Posted March 5, 2009 The Error Reporting should have showed you that. Link to comment https://forums.phpfreaks.com/topic/148132-solved-would-someone-check-this-code-please/#findComment-777621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.