databse fetch problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

databse fetch problem

Post by vigge89 »

This is how my mysql_fetch_row code looks like:

Code: Select all

<?php
$sql3 = "SELECT level FROM keeper WHERE nick = '$usrname'";
$result3 = @mysql_fetch_row( @mysql_query($sql3));
?>
The level field is an indeger(1) and where username = vigge , it's set to '5'.
However, $result[0] contains '1', and not '5'. Could anyone help me solve this mystery?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Hard when we cant see the rest of the table-content.
This should get a) error messages if there is something wrong, b) a result that should becorrect, if it's correct in the table as you say.

Code: Select all

<?php
    // Felstavning? (username)
   $result = mysql_query("SELECT level FROM keeper WHERE nick = '$usrname'") or die("Could not query:" . mysql_error());
   echo mysql_result($result, 0);
?>
Using mysql_result() to automaticly fetch the result abit faster.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

No error, but the field 'level' is set to '5' where nick = 'vigge'
Contents of table 'keeper':
Image
Post Reply