Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Mysql Row data php


ghost's Avatar
0 0

Heya guys, Im trying to make a points system for my site .. All i need now .. is to echo them :P Sounds simple yea .. But i cant seem to get the sql bit right .. Ive tried loooads of different things …. But this is my most recent attempt

<?php
function dbarray($query) {
	$result = @mysql_fetch_assoc($query);
	if (!$result) {
		echo mysql_error();
		return false;
	} else {
		return $result;
	}
}
function dbrows($query) {
	$result = @mysql_num_rows($query);
	return $result;
}
$un = $_SESSION['session_user'];
mysql_connect("localhost", "root", "***********") or die(mysql_error());
mysql_select_db("cms") or die(mysql_error());
$query = "SELECT * FROM users WHERE username=$un";
$result = mysql_query($query);
if (dbrows($result)) { $data = dbarray($result); } 
$req_points = $data->points;
echo "req_points";
?>```

ghost's Avatar
0 0

Can you remove smilies and post an output,

You are also missing an $ on the final echo


ghost's Avatar
0 0

smilies removed in above post ^ …. And yea i changed that but still ahve my prob … The last bit was an ad-lib for example anyway .. but carry on ..


ghost's Avatar
0 0

replace

if (dbrows($result)) { $data = dbarray($result); }
$req_points = $data->points;
echo "req_points";
?>

if

$data = mysql_fetch_object($result);
$req_points = $data->points;
echo "$req_points";
?>