Jump to content

why doesnt it delete <_>


Carl-Cox-

Recommended Posts

grr this is annoying me i cant fink its late why wont it delete all from the database

 

[php:1:885a98dab3]

$result = mysql_query(\"SELECT * FROM xdcc\", mysql_connect(\"localhost\",\"***\",\"***\"));

$countDB = mysql_num_rows($result);

echo $countDB.\" Rows <BR>\";

$tempno = \"1\";

while ($tempno <= $countDB){

$query = \"DELETE * FROM xdcc WHERE id = \'$tempno\'\";

$result = mysql_query($query);

$tempno++;

}

[/php:1:885a98dab3]

 

its counts teh rows and add to $tempno each time but the query isnt working :(

Link to comment
Share on other sites

try something like this:

 

[php:1:f49acaf7d6]<?php

$conn = mysql_connect(\"localhost\",\"***\",\"***\");

mysql_select_db(\"*database_here*\", $conn);

$result = mysql_query(\"SELECT * FROM `xdcc`\", $conn);

while ($row=mysql_fetch_array($result)) {

mysql_query(\"DELETE FROM `xdcc` WHERE `id`=\'\".$row[\'id\'].\"\'\", $conn);

}

mysql_close($conn);

 

?>[/php:1:f49acaf7d6]

 

for a start it doesnt know which database to work with. also maybe the id\'s in the table dont start with 1 and end with however many records there are in that table.

 

[php:1:f49acaf7d6]<?php

$result = mysql_query(\"SELECT * FROM xdcc\", mysql_connect(\"localhost\",\"***\",\"***\"));

$countDB = mysql_num_rows($result);

echo $countDB.\" Rows <BR>\";

$tempno = \"1\";

while ($tempno <= $countDB){

$query = \"DELETE * FROM xdcc WHERE id = \'$tempno\'\";

$result = mysql_query($query);

$tempno++;

}

?>[/php:1:f49acaf7d6]

 

and just to be a prick you should learn about for() http://php.net/for

 

 

[php:1:f49acaf7d6]<?php

for ($tempno=1; $tempno <= $countDB; $tempno++) {

$query = \"DELETE * FROM xdcc WHERE id = \'$tempno\'\";

$result = mysql_query($query);

}

?>[/php:1:f49acaf7d6]

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.