PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 22nd, 2004, 04:30 PM
Cliekid Cliekid is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 Cliekid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with PHP form submission...

Greets,

I seem to have a small problem with a form and how it submits. I have a delete script and the form. Now it Echos a success message but doesnt delete anything, so let me copy and paste the code:

For the Form:

<HTML>
<Body>
<form action="/corporate/testdelete.php">
<?php
$dbh=mysql_pconnect ("localhost", "cliekid", "clienr70v") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cliekid_admin");
$result = mysql_query("SELECT * FROM news");
$select = "<SELECT name=\"test\">";
$submit = "<BR><input type=\"submit\" value=\"Delete News\">";
$text = "<BR><BR>Insert Article Date: <input type=\"text\" name=\"test2\">";
$i = "0";
while ( $row = mysql_fetch_array($result) )
{
// if first itteration
if ( $i == '0' )
{
$option = "<option value=\"".$row['news_name']."\" />".$row['news_name']." - ".$row['news_date']." - By: ".$row[news_writer];
}
else
{
echo ("There is nothing to delete!");
}
}
$option.="</SELECT>";
echo $select,$option,$text,$submit; ?>
</form>
</Body>
</HTML>

For the Delete Script:

<?php
$dbh=mysql_pconnect ("localhost", "cliekid", "clienr70v") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cliekid_admin");
$sql ="DELETE FROM news WHERE news_name = '$_POST[test]' AND news_date = '$_POST[test2]'";
$result = mysql_query($sql);
if (!$result) {
die('Invalid SQL!: ' . mysql_error());
}
else
{
echo ("News Article Succesfully Deleted!"); }
?>


Any ideas? I need it so when the selected fields, date and name, are selected the article deletes via removing its row, but, it doesnt.

Help!

Thanks,

-Cliekid

Reply With Quote
  #2  
Old April 23rd, 2004, 11:00 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 5
Send a message via MSN to Spongy
Take a look at your query. Echo it and see what it returns. I guess that there's a problem with the $_POST variables.
Try this one:
PHP Code:
 $sql ="DELETE FROM news WHERE news_name = '".$_POST['test']."' AND news_date = '".$_POST['test2']."'"


And BTW, could you post in the appropiate forum next time and put your code between the assigned BB-tags?

Cheers,
__________________
Work to live, don't live to work

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help with PHP form submission...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT