php+mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mastersan
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2011 7:52 pm

php+mysql

Post by mastersan »

Hi can some on tell where i am wrong

Code: Select all

<?php
$db = mysql_connect(' ****** ',' ****** ',' ****** ') or die();
mysql_select_db(' ****** ', $db);
$result = mysql_query("set names 'utf8'");
$query = "select * from table ORDER BY id";
$result = mysql_query($query);
$userrow = mysql_fetch_array( $result );

while($userrow = mysql_fetch_array($result)){
	echo $userrow['id']. " - ". $userrow['username']. " - ". $userrow['currenthp']. " - ". $userrow['maxhp']. " - ". $userrow['gold'];
	echo "<br />";


		if($userrow["currenthp"] != ($userrow["maxhp"])){
	
		 	$result2 =mysql_query("UPDATE table SET `currenthp` = `currenthp` + '1' 
			WHERE `id` = '".$userrow["id"]."'", "users");
			
			}
			else {
			echo "NEW HP-";
			echo $userrow['id']. " - ". $userrow['username']. " - ". $userrow['currenthp']. " - ". $userrow['maxhp']. " - ". $userrow['gold'];
			echo "<br />";
			}

}
?>
and error is
Parse error: syntax error, unexpected ',' in /home/****.php on line 16
can tell any one where i am wrong
o and yes i am new in programming so don't bee ruff :)
User avatar
MindOverBody
Forum Commoner
Posts: 96
Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia

Re: php+mysql

Post by MindOverBody »

In your UPDATE query, at the end "users" is not needed... whatever it is.
mysql_query() function takes only two parameters, first is query string, and second is connection identifier which can not be string value.
Second parameter is optional. But, if you want to use connection identifier, put $db instead of "users".
Check mysql_query() function manual.

Cheers!
mastersan
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2011 7:52 pm

Re: php+mysql

Post by mastersan »

Thank you very much
Post Reply