Jump to content

quick question


paulman888888

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

$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");

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.