SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: MySQL Row deletion...PROBLEM!
-
Dec 3, 2004, 08:38 #1
- Join Date
- Oct 2004
- Location
- UK
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
MySQL Row deletion...PROBLEM!
I am having some problems with my script:
Code:$id = $HTTP_GET_VARS['id']; require("config.php"); $connect = mysql_connect($server, $username, $password); if(!$connect) { die("There is a MySQL error,<br>MySQL Returned: \n".mysql_error()); } mysql_select_db($database); mysql_query("DELETE FROM 'ragesc_clients' WHERE 'ID' = '".$id."'"); mysql_close($connect); header("location: index.php");
-
Dec 3, 2004, 09:05 #2
- Join Date
- Oct 2004
- Location
- UK
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
is anybody online?
-
Dec 3, 2004, 09:08 #3
- Join Date
- Oct 2003
- Location
- The Netherlands
- Posts
- 406
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try using $_GET['id'] instead of $HTTP_GET_VARS['id']
Also, this is not really relevant to your problem, but make sure the page you are on is a protected page, because everyone could specify the ID in the URL to delete rows from your database.
-
Dec 3, 2004, 09:15 #4
- Join Date
- Oct 2004
- Location
- UK
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i verified that before by doing this:
Code:$id = $HTTP_GET_VARS['id']; echo $id; require("config.php");
-
Dec 3, 2004, 09:16 #5
- Join Date
- Oct 2003
- Location
- The Netherlands
- Posts
- 406
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What PHP version are you using? Because you should be using $_GET regardless..
Anyway, if you're saying that echo $id throws up the ID you want to delete the row from, it will be something else in your code. Can you perhaps post your config.php file? Change the values for your username and password, I only need to take a look at its structure.
-
Dec 3, 2004, 09:18 #6
- Join Date
- Oct 2004
- Location
- UK
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
YAY!!!
I whent into my hosts controll panel and found "phpMyAdmin". I simulated a deletion and it returned:
Code:DELETE FROM `ragesc_clients` WHERE `ID` = '1' LIMIT 1; DELETE FROM `ragesc_clients` WHERE `ID` = '4' LIMIT 1;
, thanx for your help anyways, and i most definately will implement some security onto that page
-
Dec 3, 2004, 09:22 #7
- Join Date
- Oct 2003
- Location
- The Netherlands
- Posts
- 406
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The ; is only needed when you have multiple DELETE statements, so that MySQL knows where the next task starts.
Good luck with your project
-
Dec 3, 2004, 09:25 #8
- Join Date
- Oct 2004
- Location
- UK
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Good luck with your website, looks quite complex too me, though it is still unfinished because i cant download your project yet
i will bookmark that for later...
-
Dec 3, 2004, 09:26 #9
- Join Date
- Oct 2003
- Location
- The Netherlands
- Posts
- 406
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's coming along nicely... expect a beta around New Year
Thanks,
Kilroy
-
Dec 3, 2004, 09:34 #10
- Join Date
- Apr 2004
- Location
- germany
- Posts
- 4,324
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Compare your first snippet
DELETE FROM 'ragesc_clients' WHERE 'ID' = '".$id."'");
with the second
DELETE FROM `ragesc_clients` WHERE `ID` = '1'
Feel the difference...
Bookmarks