Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 1,693
Trades: 0
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
 
 
Register now for full access!
Old 06-13-2004, 01:50 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
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!'); 
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 06-13-2004, 02:48 PM
Unknown.

Posts: 1,693
Trades: 0
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, 02:54 PM
WaHoOoO!'s Avatar
Mentally Unstable Tugboat Captain

Posts: 797
Name: Chad
Location: /usr/bin/perl
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.75413 seconds with 12 queries