/    Sign up×
Community /Pin to ProfileBookmark

Unnecessary Warning on First Load of Page

Hey all,

I’m sure this is just a rookie mistake, but I can’t seem to find a way around it. Perhaps someone can take a look and help me with a resolve:

[CODE]
while ($row = mysql_fetch_array($result))
{
if ($row[‘movieID’] == $movieID)
{
$match = “y”;
}
}

if ($match != “y”)
{
echo $movieID . ” is not a valid movie ID – No delete made ***<br /><br />”;
include ‘footer.html’;
die ();
}

mysql_query(“DELETE FROM dvd WHERE movieID = ‘$movieID'”)
or exit(“<p>Error – Unable to execute query</p>”);
echo $movieID . ” was successfully deleted ***”;

mysql_close($DBconnect);
[/CODE]

What’s happening is that when you FIRST load the page, it gives a warning saying ” is not a valid movie ID – No delete made ***” because when the page first loads $match does NOT = ‘y’.

Is there a way around this? I’ve tried making $match = 0 and putting an if statement that if $match = 0 then die (); but that just gives the warning of ” was successfully deleted”.

I’m so lost and frustrated. Any suggestions are greatly appreciated.

Thanks all,
TriZz

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@kreddMay 01.2008 — hey, i'm assuming there is a form on the page that is supposed to be submitted and then have the sql run. so....try this:

wrap your sql in this and add a hidden field in your form named "process" with a value of 1 with the form method set to POST. this will only allow the sql to fire if the hidden field has been posted(ie - form is purposefully submitted with an actual movieID to be processed).

someone may have a better or more efficient idea but this always works for me.

[CODE]

if($_POST['process'] == 1) {

<<<SQL GOES INHERE >>>

}

[/CODE]
Copy linkTweet thisAlerts:
@TriZzauthorMay 02.2008 — @KREDD

Thanks a lot! Your solution worked brilliantly!

Hopefully one day, I'll be able to help those who were once me.

Again, thanks...I was getting so mad!
Copy linkTweet thisAlerts:
@kreddMay 02.2008 — no sweat! and i know exactly what you mean ?
×

Success!

Help @TriZz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...