First: I'm somewhat of a newbie to php. Just a forewarning.

I've been playing around with this code for about 4 hours. It's almost 2 AM now, and I'm finally deciding to throw in the towel. That, and I have to work tomorrow and I'll sit here trying to figure it all night if I don't ask here.

The code is below. I'm not sure what's wrong. The Query seems to pick up some variables, and the others it completely ignores. When I echo the query the variables show but they mysteriously disappear after the page reloads. No updates to the table or anything. I hope I'm explaining it right.

I thought I'd finally fixed it when I got to the point where I didn't get any syntax errors, but that hope was short-lived when the errors disappeared but the problem was the same.

Although I'm a newbie, I'll try my best to comprehend whatever it is you have to say that might help me. If someone can help me. I'd really appreciated it. Thanks.


if (isset($_POST["id"]))


    $query = "UPDATE ads SET ad_url='$url', ad_description='$description', clicksleft='$clicksleft', ad_title='$ad_title' 

WHERE ad_id='$id'";
echo $query;

    mysql_query($query) or die(mysql_error());

    echo "<b>The Advertisement has been successfully edited.</b><br><br>";


if (isset($_GET["id"]))


if ($option=="edit"){

9 Years
Discussion Span
Last Post by andyhoneycutt

Would you mind posting the code for the page that posts to this one? That may help narrow down the issues you're having. Also, I would suggest escaping your data before you pass it off to your database. Using mysql_real_escape_string(<$data>,<$database_link>) will help to prevent sql injection attacks.

You may also try to nail down the problem by using a print_r() statement on your $_POST and $_GET globals to make sure all the data is actually making it to your page.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.