Page 1 of 1

Delete help

Posted: Tue Feb 03, 2009 9:04 pm
by Tsongkie
I'm having a problem deleting the row i just fetched and showed. I'm doing it to play with mysql database i got from fakenamegenerator.com to show the first row found, and then delete it so the next time i reload the script it shows the second row in the database.

Help would be much appreciated

Code: Select all

 
<?php
 
$dbh=mysql_connect ("localhost", "flipsoft_tsongki",
"muncher") or die('Cannot connect to the database because: ' . mysql_error());
 
mysql_select_db ("flipsoft_esubmit");
 
$query  = "SELECT number, gender, givenname,middleinitial, surname, streetaddress, city, state, zipcode, country, emailaddress, telephonenumber, maidenname, birthday, cctype, ccnumber, cvv2, ccexpires, nationalid, upstracking FROM fakenames";
 
$result = mysql_query($query,$dbh);
 
$row = mysql_fetch_row($result);
 
echo $row[0] . '<br />' .
$row[1] . '<br />' .
$row[2] . '<br />' .
$row[3] . '<br />' .
$row[4] . '<br />' .
$row[5] . '<br />' .
$row[6] . '<br />' .
$row[7] . '<br />' .
$row[8] . '<br />' .
$row[9] . '<br />' .
$row[10] . '<br />' .
$row[11] . '<br />' .
$row[12] . '<br />' .
$row[13] . '<br />' .
$row[14] . '<br />' .
$row[15] . '<br />' .
$row[16] . '<br />' .
$row[17] . '<br />' .
$row[18] . '<br />' .
$row[19] . '<br />' ;
 
$deleteSQL=("DELETE FROM fakenames WHERE number=$row");
 
$result2 = mysql_query($deleteSQL,$dbh);
 
 
mysql_close($dbh);
 
?> 
 

Re: Delete help

Posted: Tue Feb 03, 2009 9:24 pm
by requinix
$row is an array. If you want a part of the array (like $row[0] or $row[99], how you did a couple lines above it) then you need to say so.