Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-13-2003, 02:42 PM   #1
Gasper
Guest
 
Posts: n/a
PHP experts .. please help!!

I'm trying to make a script to delete a row from a mysql table ......

Can someone tell me what's wrong ??!?

Please take a look on the last 7 lines .. without them it works (but the script is not complete)


PHP Code:

<form method="get" action="update.php"> 
<?
mysql_pconnect("localhost","username","password"); 
mysql_select_db("databasename"); 
if(!$submit)
{
    $result = mysql_query("select * from poly_links order by id"); 
    while($r=mysql_fetch_array($result)) 
    { 
        
        $id=$r["id"];        
        $songname=$r["songname"];
        $author=$r["author"];

                ?>
        <INPUT TYPE="RADIO" NAME="id" VALUE="<?php echo $id;?>"><br> 
        <?php echo $id;?> 
        <?php echo $songname;?>
        <?php echo $author;?><br> 
<?
    }?>
<input type="submit" value="submit" name="Submit"></form> 
<?
}?> 

<?
else
{
    $sql = "DELETE FROM poly_links WHERE id=$id";
    $result = mysql_query($sql);
    echo "News Deleted.";
}?>
  Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-13-2003, 02:52 PM   #2
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
$sql = "DELETE FROM poly_links WHERE id='$id';";
$result = mysql_query($sql);


Try this
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-13-2003, 02:55 PM   #3
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
Does have $id a vaule??

Just put on top

print "id value :$id<br>\n";

then you know it has a value..otherwise there is nothing to delete
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-13-2003, 03:01 PM   #4
twitchkat
Registered User
 
Join Date: Apr 2003
Posts: 2
Code:
{

    $sql = "DELETE FROM poly_links WHERE id=$id";

    $result = mysql_query($sql);

    echo "News Deleted.";

}
I bet $id hasn't been defined when you set $sql.

You can verify this by putting:

Code:
die("SQL QUERY: " . $sql);
after the $sql assignment. If it resolves to:

DELETE FROM poly_links WHERE id=

then that's not valid SQL.

Grumpy's quoting suggestion is good practice.
twitchkat is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-13-2003, 03:13 PM   #5
apscripts
Confirmed User
 
Join Date: Mar 2003
Location: Los Angeles, CA USA
Posts: 204
The quoting isn't necessary for numeric characters, if the field id is in fact numeric. You should write a function to convert all your empty numeric values to NULL and to quote all your strings. A lot of people call these clean up functions, etc. Also mysql_query does not return anything on DELETE or INSERT. So there is no sense in setting $result to nothing

I don't know what error you're getting, but chances are you have no value in $id as suggested previously.

Also - I am *guessing* that I cannot see your entire script - but if that *is* the whole script, you need register_globals on...which is a very, very bad thing to do. register_globals if for pretend environments.
__________________
icq5708193

aptgp III -- Build a Blog, an RSS feed, a text TGP, and a thumb TGP all from one installation. Own Comus or AutoGallery? Have APTGP III Installed free for 30 days; no obligations.
apscripts is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.