/    Sign up×
Community /Pin to ProfileBookmark

Delete from mysql database

wanna delete from database and i have write follwoing code

[code=php]
$item = $_GET[“id”];
echo $item;

$dbh=mysql_connect (‘localhost’,’root’,’root’);
mysql_select_db (“class”);
$query=”Delete From categorytable where catid=”+$item;
echo $query;
mysql_query($query);

[/code]

but it is nor printing the query when i write echo statmnet
neither deleting record.
what need to do further

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@replicaAug 08.2007 — most likely mysql_connect() or mysql_select_db() are failing but you should see the errors for that... unless they're turned off.

Does PHP render anything?
Copy linkTweet thisAlerts:
@ali_razaauthorAug 08.2007 — yes db conection is working fine in fact $item get the data from query string

and its printing its value on browser too....?
Copy linkTweet thisAlerts:
@jenyAug 08.2007 — try this...

[code=php]

$item = $_GET["id"];
echo $item;

$dbh=mysql_connect ('localhost','root','root');
mysql_select_db ("class");
$query="Delete From categorytable where catid=$item";
echo $query;
mysql_query($query);

[/code]

this works for me..
Copy linkTweet thisAlerts:
@replicaAug 08.2007 — 
$query="Delete From categorytable where catid="+$item;[/quote]



$query="Delete From categorytable where catid=$item";[/quote]


yeh... damn

[code=php]$query="Delete From categorytable where catid=" . $item;
[/code]


I should've seen that. do not drink and code =)
×

Success!

Help @ali_raza 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.20,
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,
)...