Reply
Deleting data from MySQL database
Old 06-13-2004, 11:26 AM Deleting data from MySQL database
Unknown.

Posts: 1,693
I found the following code for deleting data from a MySQL database...

Code:
<?php
mysql_connect("localhost","Username","Password")  
or 
die("could not connect"); 
mysql_select_db(users); 

	$sql = "DELETE FROM users WHERE userid=7";
    $result = mysql_query($sql);
?>
So in this case i want to be deleting the row where the userid is 7 in the users table...

Although it doesn't seem to work, is there an error in the code or anything???

Thanks

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-13-2004, 12:50 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,111
Location: Toronto, Ontario
You need to have quotes around 'users' in mysql_select_db, for starters.
PHP Code:
mysql_select_db('users'); 
And you can always place an if to see if anything happened.

PHP Code:
if(mysql_affected_rows() < 1)
    die(
'Nothing happened!'); 
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 06-13-2004, 01:48 PM
Unknown.

Posts: 1,693
Thanks

I also noticed i had put the table name instead of the database name

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 06-13-2004, 01:54 PM
WaHoOoO!'s Avatar
Mentally Unstable Tugboat Captain

Posts: 797
Name: Chad
Location: /usr/bin/perl
Yeah, it reminds me of the ThinkGeek shirt:

SELECT FROM users WHERE clue > 0
0 Rows Returned.
__________________
He's baaaaaaaack....
WaHoOoO! is offline
Reply With Quote
View Public Profile Visit WaHoOoO!'s homepage!
 
Reply     « Reply to Deleting data from MySQL database
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12892 seconds with 12 queries