Delete help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tsongkie
Forum Newbie
Posts: 13
Joined: Sun Feb 01, 2009 6:51 pm

Delete help

Post 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);
 
?> 
 
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Delete help

Post 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.
Post Reply