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"]))
{

$ad_id=$_POST["ad_id"];
$plan=$_POST["plan"];
$url=$_POST["url"];
$description=$_POST["description"];
$clicksleft=$_POST["clicksleft"];
$ad_title=$_POST["ad_title"];

    $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"]))
{

$id=$_GET["id"];
$option=$_GET["option"];


if ($option=="edit"){

?>

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.

-Andy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.