/    Sign up×
Community /Pin to ProfileBookmark

delete mysql script problem

what am i doing wrong with this script?

this is to initiate the delete

[code=php]
echo ‘<td><a href=”?id=admin&admin=eart&table=kj_art&delete=’.$row[‘id’].’&data=’.$row[‘art_title’].'”>Delete</a></td>’;

delete();
[/code]

[code=php]
function delete()
{
if (isset($delete))
{
$query = “DELETE FROM $table WHERE id=’$delete'”;
mysql_query($query) or die(mysql_error());
echo “Data Deleted: “.$data.”!”;
}
}
[/code]

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@chazzyApr 26.2006 — where are you defining $table?
Copy linkTweet thisAlerts:
@knowjauthorApr 26.2006 — sorry must have posted old code

[code=php]
echo '<td><a href="?id=admin&admin=eart&table=kj_art&delete='.$row['id'].'&data='.$row['art_title'].'">
Delete</a></td>';

[/code]
Copy linkTweet thisAlerts:
@chazzyApr 26.2006 — I still don't see it.

Can you post the error that you're getting.
Copy linkTweet thisAlerts:
@knowjauthorApr 26.2006 — in the link

eart&table=kj_art&delete=

im not getting an error its just not working :S
Copy linkTweet thisAlerts:
@chazzyApr 26.2006 — it sounds like your script doesn't know what $delete is, looks like a scope issue. create a function that takes 2 parameters: table and delete
Copy linkTweet thisAlerts:
@knowjauthorApr 26.2006 — http://www.knowj.com/?id=admin&admin=emem&table=kj_users&delete=37&[email protected]

thats an example of a link and it shows it sets $delete and $table
Copy linkTweet thisAlerts:
@chazzyApr 26.2006 — right, but inside the function, can it read the $delete and $table that are outside the function? I'm thinking no, you have a scope issue. if you want, you can use global $delete,$table but I don't think that it'll be all that useful honestly.
Copy linkTweet thisAlerts:
@knowjauthorApr 27.2006 — is there a better way you would reccomend setting up a delete function?
×

Success!

Help @knowj 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...