php mysql result

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
birdie
Forum Newbie
Posts: 22
Joined: Thu Sep 15, 2005 4:37 pm

php mysql result

Post by birdie »

hi, ive made this script but it doesnt work..

Code: Select all

<?
mysql_connect("localhost","root","password");
mysql_select_db("dave");
$voteresult = mysql_query("SELECT number FROM votegood WHERE dave=1");
$number = mysql_result($voteresult);
mysql_query("UPDATE votegood SET number=$number+1 } WHERE dave=1");
mysql_close();
?>


could someone please tell me whats wrong with that, error messages say its this part, "$number = mysql_result($voteresult);". thanks
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

http://ee.php.net/manual/en/function.mysql-result.php

what do you need mysql_result for? this i often not nessicary.
birdie
Forum Newbie
Posts: 22
Joined: Thu Sep 15, 2005 4:37 pm

Post by birdie »

well i'm just trying to get it to work. would this help?.. i have a table in mysql like this..

------
|n|id|
------
|1|2|
------

i want to echo the "1" in the "n" column. how do i do this?
xtjdx
Forum Newbie
Posts: 5
Joined: Sun Oct 09, 2005 3:23 am

Post by xtjdx »

The way I usually do MySQL results is:

Code: Select all

<?
$query = 'Select field From table Where value=\'value\'';
$result = mysql_query($query);
$result = mysql_fetch_array($result);
echo $result['field'];
?>
Never used mysql_result().
Post Reply