FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


mysql problem





haziwkd
i want to execute select and update in one query
how can i do?

i wrote:
$sql="UPDATE `viewcount` SET `count` = `count` +1 LIMIT 1 ;
SELECT * FROM `viewcount`";
mysql_query($sql,$link);

then............
You have an error in your SQL syntax near '; SELECT * FROM `viewcount`' at line 1
mathiaus
Dont know if you can do it all in one query. Even if you can it'll most likrly be tricky or something.
Whats wrong with multiple queries?
haziwkd
i want to make a counter
if i want to update the number number of visit before show the number of visit
then i wrote:
$sql="UPDATE `viewcount` SET `count` = `count` +1 LIMIT 1" ;
mysql_query($sql,$link);
$sql="SELECT * FROM `viewcount`";
mysql_query($sql,$link);

i just want to how can i do that in another way
kv
haziwkd wrote:
i want to make a counter
if i want to update the number number of visit before show the number of visit
then i wrote:
$sql="UPDATE `viewcount` SET `count` = `count` +1 LIMIT 1" ;
mysql_query($sql,$link);
$sql="SELECT * FROM `viewcount`";
mysql_query($sql,$link);

i just want to how can i do that in another way


If you want to display the original count before update, all you need to do is execute select before the update and store the count in a variable.
ml
Quote:
i just want to how can i do that in another way


no you cant.
mysql isnt able to execute multipe queries, it returns an error after the first ;
abhinav_shah
You can't execute multiple queries in MySql.
haziwkd
ok
thanks all~
Related topics
mysql problem
ALTER TABLE mySQL problem.
What is useful way in this php+mysql problem?
MySQL problem...
Mysql problem
MySQL HELP!!
MySQL problem (as usual)
MySQL problem :'(
MySQL Problem
mysql problem
mySQL problem
header already sent? (and now introducing a mysql problem)
server -4 Mysql problem
MySQL problem - Can't insert stuff in to database
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.