nadinengland Posted November 8, 2006 Share Posted November 8, 2006 Riiight im having trouble with my coding... *dur*I want to be able to go to "delete.php" say with "?postID=10" at the end, and do the following...[code]<?php $con = mysql_connect("host","username","password");mysql_select_db("database", $con);$postIDdel = $_GET['postID'];$sql_delete = 'DELETE FROM yearbook WHERE postID="$postIDdel"';if (mysql_query($sql_delete,$con)) { mysql_query($sql_delete,$con); header("Location: http://www.tea-and-crumpets.com/yearbook/admin-delete.php"); exit; }else {echo "<b>Error deleteing post:</b> " . mysql_error();}?>[/code]Now... that doesn't work... it does take you to admin-delete afterwords, but doesnt delete the post.I know its something to do with the $sql_delete line, but im not sure what.Thanks alot. nad Quote Link to comment Share on other sites More sharing options...
shoz Posted November 8, 2006 Share Posted November 8, 2006 [quote=nadinengland]'DELETE FROM yearbook WHERE postID="$postIDdel"'[/quote]Variables are not expanded when inside a single quoted string.Change the single quotes to double quotes and the doubles to singles. In the posted code snippet you also have 2 calls to mysql_query(). I assume you meant to only have the first one.[quote=nadinengland]if (mysql_query($sql_delete,$con)) { mysql_query($sql_delete,$con);[/quote] Quote Link to comment Share on other sites More sharing options...
nadinengland Posted November 8, 2006 Author Share Posted November 8, 2006 tah man! i didnt know about " ' thanks alot!im gunna stay here, it will help my php skillz! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.