Jump to content

[SOLVED] Resource id #5 ??? Wrong


prima

Recommended Posts

OK, i have this kind of a problem, all seems working fine but it just displays Resource id #5  an id#6 and not the number that is in the database.


[quote]<?php
include 'connectdb.php';
session_start();

$regst="SELECT regst FROM number";  //in phpmyadmin it gives a number 4 that is correct, but here it doesn't
$rezultat = mysql_query($regst) or die("Error no reg users") ;

$onlinest="SELECT onlinest  FROM number";
$rezultat2 = mysql_query($onlinest) or die("Error no online users") ;


echo "$rezultat ";  //here should be 4
echo "$rezultat2"; //here 0


include 'closedb.php';

?>
[/quote]
Link to comment
https://forums.phpfreaks.com/topic/33380-solved-resource-id-5-wrong/
Share on other sites

The mysql_query function just returns a pointer to the result set. You need to use one of the mysql_fetch functions to actually get the value(s) retrieved:
[code]<?php
include 'connectdb.php';
session_start();

$regst="SELECT regst FROM number";  //in phpmyadmin it gives a number 4 that is correct, but here it doesn't
$rezultat = mysql_query($regst) or die("Error no reg users") ;
$rw = mysql_fetch_assoc($resultat); // inserted this statement
$onlinest="SELECT onlinest  FROM number";
$rezultat2 = mysql_query($onlinest) or die("Error no online users") ;
$rw2 = mysql_fetch_assoc($rezultat2); // inserted this statement

echo $rw['regst'].'<br>';  //here should be 4
echo $rw2['onlinest']; //here 0
// changed the above two statements

include 'closedb.php';

?>[/code]

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.