PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > The PowWeb Platform > MySQL
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Closed Thread
 
Thread Tools Search this Thread
Old 1-6-05, 01:32 PM   #1
j2swift
 
Posts: n/a
Cannot Delete Mysql record through php script

Im having trouble deleting records through php.
I don't know if it could be a setting in my php.ini file or what.
Below is the script with what im trying to do

mysql_query("DELETE FROM `table` WHERE `no` = '58' LIMIT 1");

if (mysql_affected_rows() == 1){
echo "<p>You have successfully deleted this item!</p>";
} else {
echo "<p>Error! Item not deleted</p>";
}
 
Old 1-6-05, 01:40 PM   #2
mitchind
Older not wiser
 
mitchind's Avatar
 
Join Date: Nov 2003
Location: Calgary, AB
Posts: 2,473
Reputation: 205
I'd try your SQL syntax first in phpMyAdmin to see if it works there first. Otherwise you're not sure if its a php problem or SQL syntax.

I'm not sure but I think it might be the LIMIT clause you have on the end.
Doesn't it need a start number and number of records?
mitchind is offline  
Old 1-6-05, 02:01 PM   #3
j2swift
 
Posts: n/a
I tried that already and it works on phpMyAdmin
 
Old 1-6-05, 03:20 PM   #4
HalfaBee
 
HalfaBee's Avatar
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 7,130
Reputation: 333
I assume you have done all the connection stuff for mysql.
__________________
I don't suffer from laziness, I enjoy every minute!
Edit your php.ini here
http://members.powweb.com/member/cgi...nt/PHPplus.bml
HalfaBee is offline  
Old 1-6-05, 03:25 PM   #5
j2swift
 
Posts: n/a
Yes I have, it's weird i have used the same setup for my other queries on my site and they all work fine. I am just having trouble with this DELETE query. What im trying to do exactly is to provide a link in a table that when clicked will pass the value of the row to be deleted to a delete.php page that receives this value and runs the query to delete the specified row.
 
Old 1-6-05, 03:28 PM   #6
HalfaBee
 
HalfaBee's Avatar
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 7,130
Reputation: 333
Try echoing the SQL and testing for any errors.
mysql_query( $sql ) or die( $sql . mysql_error() );
__________________
I don't suffer from laziness, I enjoy every minute!
Edit your php.ini here
http://members.powweb.com/member/cgi...nt/PHPplus.bml
HalfaBee is offline  
Old 1-6-05, 04:16 PM   #7
j2swift
 
Posts: n/a
Hey thanks a lot guys !

I found that the problem was with the access granted to the user defined in my sqcript.

When I did :
mysql_query($query) or die( $sql . mysql_error() );

I learned that the user did not have access granted to delete.

Again thanks a million!
 
Closed Thread


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 02:41 PM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright © 2000-2007 Jelsoft Enterprises Limited.