paulman888888 Posted June 20, 2008 Share Posted June 20, 2008 please can someone tell me what i have done wrong. I would of liked it to echo just the 1 ipaddress then delete it but i have done something wrong. Below is me code. <?php include("connect.php"); ?> <?php $query = "SELECT * FROM intowar1"; $result = mysql_query($query) or die("ERROR LEVEL 3"); $row = mysql_fetch_array($result) or die("ERROR LEVEL 4"); echo $row['ipaddress']; mysql_query("DELETE FROM example WHERE ipaddress=$row['ipaddress']") or die("ERROR LEVEL 5"); ?> Please help me fix it. Thankyou Quote Link to comment https://forums.phpfreaks.com/topic/111161-quick-question/ Share on other sites More sharing options...
sebthib55 Posted June 20, 2008 Share Posted June 20, 2008 please can someone tell me what i have done wrong. I would of liked it to echo just the 1 ipaddress then delete it but i have done something wrong. Below is me code. <?php include("connect.php"); ?> <?php $query = "SELECT * FROM intowar1"; $result = mysql_query($query) or die("ERROR LEVEL 3"); $row = mysql_fetch_array($result) or die("ERROR LEVEL 4"); echo $row['ipaddress']; mysql_query("DELETE FROM example WHERE ipaddress=$row['ipaddress']") or die("ERROR LEVEL 5"); ?> Please help me fix it. Thankyou Should mysql_query("DELETE FROM example WHERE ipaddress=$row['ipaddress']") or die("ERROR LEVEL 5"); be mysql_query("DELETE FROM intowar1 WHERE ipaddress=$row['ipaddress']") or die("ERROR LEVEL 5"); If thats not it, then what is your code doing? Is it not deleting anything? Quote Link to comment https://forums.phpfreaks.com/topic/111161-quick-question/#findComment-570522 Share on other sites More sharing options...
peranha Posted June 20, 2008 Share Posted June 20, 2008 $query = "SELECT * FROM intowar1"; should be something like $query = "SELECT * FROM intowar1 WHERE ipadd = '$ipnumber'"; you are currenty selecting all addresses. then $row = mysql_fetch_row($result) or die("ERROR LEVEL 4"); Quote Link to comment https://forums.phpfreaks.com/topic/111161-quick-question/#findComment-570525 Share on other sites More sharing options...
paulman888888 Posted June 20, 2008 Author Share Posted June 20, 2008 sorry am confused. I didnt use the while function or loop so i thought it should only put out 1 ipaddress. Ill scrap that code then. Ill start again. I got my table intowar1, i would like it to pull out and echo the latest ipaddress, (i do have a column called id that is an auto number if that helps, highest number is the newest). Then delete that row straight after. Can someone please make an example please. Quote Link to comment https://forums.phpfreaks.com/topic/111161-quick-question/#findComment-570539 Share on other sites More sharing options...
fenway Posted June 20, 2008 Share Posted June 20, 2008 Quote your variable. Quote Link to comment https://forums.phpfreaks.com/topic/111161-quick-question/#findComment-570563 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.