/    Sign up×
Community /Pin to ProfileBookmark

php delete file not deleting from SQL table

here is the code:

<?php

$Link = @mysql_connect(‘mydata’, ‘mydata’, ‘mydata’);
if (!$Link) {
exit(‘<p>Unable to connect to the ‘ .
‘database server at this time.</p>’);
}

if (!@mysql_select_db(‘mydata’)) {
exit(‘<p>Unable to locate the PartyCo ‘ .
‘database at this time.</p>’);
}

// delete joke part

$party = $GET_[‘party’];
$ok = @mysql_query(
“DELETE FROM christmas WHERE party=’$party'”);
if ($ok) {
echo ‘<p>Party deleted successfully!.</p>’;
} else {
echo ‘<p>Error deleting party details: ‘ .
mysql_error() . ‘</p>’;
}

?>

this script runs without error – but doesnt delete the data in the christmas table –

this is the link that sends to the delete.php page:

“<a href=’deleteparty.php?party=$party’>Delete</a></p>”;

which isnt the problem, as I have an edit.php file wchich uses the same logic and this works fine……

any suggestion to my DELETE command ?

thanks in advance!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJun 26.2010 — $party is never going to have a value because you are referencing $GET_ rather than $_GET. When you are developing you should have error_reporting enabled and set to a high level such as E_ALL | E_STRICT. If you had, PHP would have pointed out the error, including which line it was on.

You also have an extremely dangerous SQL injection vulnerability in your current code which allows an attacker to very easily delete every bit of data from your table (amongst other things). You should always be cleaning and validating user input.
Copy linkTweet thisAlerts:
@aarondmauthorJun 26.2010 — thanks for the reply.

Do you know of any websites with tutorials for cleaning up the SQL injection flaws in my code - still new to PHP/SQL

any help much appreciated....

thanks again

Aaron
Copy linkTweet thisAlerts:
@NogDogJun 26.2010 — Regarding SQL injection, see the [url=http://php.net/mysql_real_escape_string]mysql_real_escape_string() manual page[/url], and for more info: http://www.nyphp.org/PHundamentals/5_Storing-Data-Submitted-Form-Displaying-Database. And for a quick illustration as to why: http://xkcd.com/327/.
×

Success!

Help @aarondm 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.18,
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,
)...