| | |
Not able to delete a title...help please!
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 28
Reputation:
Solved Threads: 0
Hello everyone!
I have a table with titles that have a link to delete the record.
Clicking on the link, redirects the user from (members.php) to a page (delete.php )where it says that the title is deleted and the user can click another link to return to the table. The problem is that the title is never deleted. Could anyone please tell me what's wrong with my code?
This is the table that redirects the user:
And I've attached the delete.php file.
Thanks in advance!
I have a table with titles that have a link to delete the record.
Clicking on the link, redirects the user from (members.php) to a page (delete.php )where it says that the title is deleted and the user can click another link to return to the table. The problem is that the title is never deleted. Could anyone please tell me what's wrong with my code?
This is the table that redirects the user:
php Syntax (Toggle Plain Text)
echo '<tr>'. '<td>'.$row['title'].'</td>'.'<td>'.$row['category'].'</td>'.'<td>'.$row['year'].'</td>'. '<td>'.'<font size="2"><a href="edit.php?autoid="'.$row['autoid'].'"> edit</a></font>'.'</td>'.'<td>'.'<font size="2"><a href="delete.php?autoid="'.$row['autoid'].'" >delete</a></font>'.'</td>'. '</tr>';
Thanks in advance!
Last edited by peter_budo; Apr 10th, 2009 at 10:18 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
it is unneccessary, and often makes you miss a quote, to drop in and out of php text for every html tag
when it displays the table, view source to make sure the delet <a href ?parameter is populated with an id, stranger things happen, the error may be in the prior sql query
and
php Syntax (Toggle Plain Text)
echo '<tr><td>'.$row['title'].'</td><td>'.$row['category'].'</td><td>'.$row['year'].'</td> <td><font size="2"><a href="edit.php?autoid="'.$row['autoid'].'"> edit </a></font></td> <td><font size="2"><a href="delete.php?autoid="'.$row['autoid'].'" >delete</a></font></td></tr>';
and
$query4= "delete from movie where autoid='$id'"; looks right Last edited by almostbob; Apr 9th, 2009 at 10:32 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Apr 2009
Posts: 257
Reputation:
Solved Threads: 37
use this code, becuase you dont have form in ur first html section
PHP Syntax (Toggle Plain Text)
if(isset($_REQUEST['autoid'])) { $connection=@mysql_connect($host, $user, $pass)or die("Unable to connect!"); mysql_select_db($db, $connection) or die ('Unable to select database!'); $id=$_REQUEST['autoid'] ; $query4= "delete from movie where autoid=$id"; $result2=mysql_query($query4) or die ("query failed!"); echo "Title deleted"; ?> </br> </br> </br> </br> </br> <?php } else { echo "not deleted!"; } ?> <a href="members.php">Back to main page</a>
•
•
Join Date: Sep 2008
Posts: 28
Reputation:
Solved Threads: 0
•
•
•
•
it is unneccessary, and often makes you miss a quote, to drop in and out of php text for every html tag
when it displays the table, view source to make sure the href ?parameter is populated with an id, stranger things happenphp Syntax (Toggle Plain Text)
echo '<tr><td>'.$row['title'].'</td><td>'.$row['category'].'</td><td>'.$row['year'].'</td> <td><font size="2"><a href="edit.php?autoid="'.$row['autoid'].'"> edit </a></font></td> <td><font size="2"><a href="delete.php?autoid="'.$row['autoid'].'" >delete</a></font></td></tr>';
and
$query4= "delete from movie where autoid='$id'";if the id is numeric, may not need the single quotes around it in the sql
$query4= "delete from movie where autoid=$id";
Thanks for your reply! I've tried the query without the single quotes and now it says quey failed in the page.
When I looked in the URL it looked like this:
http://localhost/delete.php?autoid=
There is no id number after autoid. It's like it never recieved a number..
BzzBee nailed it
the field isnt populated
the field isnt populated
if(isset($_REQUEST['autoid'])) Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Sep 2008
Posts: 28
Reputation:
Solved Threads: 0
•
•
•
•
use this code, becuase you dont have form in ur first html section
PHP Syntax (Toggle Plain Text)
if(isset($_REQUEST['autoid'])) { $connection=@mysql_connect($host, $user, $pass)or die("Unable to connect!"); mysql_select_db($db, $connection) or die ('Unable to select database!'); $id=$_REQUEST['autoid'] ; $query4= "delete from movie where autoid=$id"; $result2=mysql_query($query4) or die ("query failed!"); echo "Title deleted"; ?> </br> </br> </br> </br> </br> <?php } else { echo "not deleted!"; } ?> <a href="members.php">Back to main page</a>
Thank you for your reply!
I've tried replacing get to request, but it still says query failed.
•
•
Join Date: Jul 2008
Posts: 148
Reputation:
Solved Threads: 25
Then the problem is in the code prior to:
as it doesn't appear to actually be returning an autoid.
php Syntax (Toggle Plain Text)
echo '<tr>'. '<td>'.$row['title'].'</td>'.'<td>'.$row['category'].'</td>'.'<td>'.$row['year'].'</td>'. '<td>'.'<font size="2"><a href="edit.php?autoid="'.$row['autoid'].'"> edit</a></font>'.'</td>'.'<td>'.'<font size="2"><a href="delete.php?autoid="'.$row['autoid'].'" >delete</a></font>'.'</td>'. '</tr>';
as it doesn't appear to actually be returning an autoid.
If you're question/problem is solved don't forget to mark the thread as Solved!
-- Code I post is usually but not always tested. If it is tested it will be against 5.2.11 or 5.3.0
-- Code I post is usually but not always tested. If it is tested it will be against 5.2.11 or 5.3.0
•
•
Join Date: Sep 2008
Posts: 28
Reputation:
Solved Threads: 0
•
•
•
•
Then the problem is in the code prior to:
php Syntax (Toggle Plain Text)
echo '<tr>'. '<td>'.$row['title'].'</td>'.'<td>'.$row['category'].'</td>'.'<td>'.$row['year'].'</td>'. '<td>'.'<font size="2"><a href="edit.php?autoid="'.$row['autoid'].'"> edit</a></font>'.'</td>'.'<td>'.'<font size="2"><a href="delete.php?autoid="'.$row['autoid'].'" >delete</a></font>'.'</td>'. '</tr>';
as it doesn't appear to actually be returning an autoid.
•
•
Join Date: Sep 2008
Posts: 28
Reputation:
Solved Threads: 0
I've made small change in the table, just to see if the autoid numbers appeared and it did! I added an extra row.
This is what I did:
It extracts the autoid number and shows it in the table, but somehow it doesn't pass the value to the url or the query in the other file...
This is what I did:
PHP Syntax (Toggle Plain Text)
while ($row = mysql_fetch_assoc($result2)) { echo '<tr>'. '<td>'.$row['title'].'</td>'.'<td>'.$row['category'].'</td>'.'<td>'.$row['year'].'</td>'. '<td>'.'<font size="2"><a href="edit.php?autoid="'.$row['autoid'].'"> edit</a></font>'.'</td>'.'<td>'.'<font size="2"><a href="delete.php?autoid="'.$row['autoid'].'" >delete</a></font>'.'</td>'. '<td>'.$row['autoid']. '</tr>'; }
Last edited by totalnoob; Apr 9th, 2009 at 11:22 am.
![]() |
Similar Threads
- mysql - problem using delete (PHP)
- How to delete a data structure in Builder 6.0? (C++)
- Hijack Log - What can I delete???? (Viruses, Spyware and other Nasties)
- correct errors in this program (C)
- how to delete ALL temp internet files, etc. (Windows NT / 2000 / XP)
- tool bar in Internet Explorer title stchchbjxcr (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: validate checkboes
- Next Thread: Next fifteen days date
| Thread Tools | Search this Thread |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube






