473,379 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

'Delete From' Issue

38
Hi there,

Can anyone spot why this scrip isn't working.

It returns "row deleted" fine, yet doesn't delete.

Expand|Select|Wrap|Line Numbers
  1. <?
  2. include("connect.php"); 
  3.  
  4. if($_GET["cmd"]=="delete")
  5. {
  6.     mysql_query("DELETE FROM events WHERE eventNumber='$id'");
  7.  
  8.     $result = mysql_query or die("Error: ". mysql_error());
  9.     echo "Row deleted!";
  10. }
  11. ?>
  12.  
  13.  
  14.  
  15.  
  16.  
  17.     <?
  18. include("connect.php"); 
  19.  
  20. if(!isset($cmd)) 
  21. {
  22.    $result = mysql_query("select * from events order by eventName"); 
  23.  
  24.    while($r=mysql_fetch_array($result)) 
  25.    { 
  26.  
  27.       $title=$r["eventName"];
  28.       $id=$r["eventNumber"];
  29.         $location=$r["eventLocation"];
  30.           $date=$r["eventDate"];
  31.  
  32.      echo "<span class='smalltitle'>$title</span><br><span class='bodytext'>$location<br>$date</span><br> "; 
  33.       echo "<a href='delete_event.php?cmd=delete&id=$id' class='links'>$title - Delete</a><br><br>";
  34.  
  35.     }
  36. }
  37. ?>
  38.  
  39.  
Many thanks.
Aug 14 '09 #1
6 1421
gopan
41
try to echo the value of $id too... it is blank thats why its not removing the row

change $id to $_GET['id']... and check
Aug 14 '09 #2
Philth
38
Sorry, I don't understand. The $id in the DELETE FROM query?
Aug 14 '09 #3
gopan
41
yup... in query... change it to $_GET['id']
Aug 14 '09 #4
Dormilich
8,658 Expert Mod 8TB
line #6: nothing will happen if the query fails.

line #8: an undefined constant is redefined as variable (not enough to trigger die()), if you have error notices on you’ll receive a notice about that
Aug 14 '09 #5
Philth
38
Great, thanks alot guys.
Aug 14 '09 #6
Dormilich
8,658 Expert Mod 8TB
sure, I’m glad I could help.
Aug 14 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: UDBDBA | last post by:
All: Anyone had bad experience with doing DECLARE DGTT "WITH REPLACE" option? The suggested workaround was to do "DELETE FROM DGTT" sql statement. We are seeing DGTT performance issue when...
2
by: Dave Burt | last post by:
Hi, Access officionados, I'm new here, so please cut me slack/gently tell me off if I'm out of line or in the wrong place. OK, here's something that seems silly (and is also problematic to...
4
by: darrel | last post by:
I'm still struggling to find out why I keep getting Invalid object name 'monkey'. errors. Below is my try/catch statement. Note the first query is trying to delete a record in the table...
4
by: MasterChief | last post by:
I am trying to learn how to delete multple items in a database using the code behind file. I would just like somebody to tell me what is wrong with my code. I am new to connecting to the database...
9
by: nnelson | last post by:
I have a base customer table of 2 million records. We're doing some testing and I added 33000 rows incorrectly. No biggie, we'll just delete them, right? Nope....9 hours later, process is still...
4
by: Ian | last post by:
Hi, I have a problem with delete using where in clause. This is a query: delete from tab1 where id not in (select id from tab2) I calculated costs using select instead of delete: select...
3
by: rn5a | last post by:
I am trying to delete records from a MS-Access DB table using the following query: strSQL=DELETE FROM MyTable WHERE =CInt(Request.QueryString("delete")) con.Execute strSQL When I run the app...
1
by: officegeek | last post by:
I have a gridview that is populated via page_load. I can get the delete to work but get an error after it deletes. The error is below the index value that is returned is the one that is deleted...
0
by: sandeepdaggupat | last post by:
Hi all, I have a custom java program which deletes rows in the DB2 database based on certain rules. Below is the query sql2 = "DELETE FROM " + mdOwner + ".QRP_STATUS_JOB_PRM WHERE...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.