Variable issue

Hi all,

I am simply trying to make a variable ‘getfee’ = a stored value for a particular ‘client’, however it seems to constantly set the value of ‘$getfee’ to 0.

	$getfee = "select fee from client where name=' .$client. ' ";

	if (!mysqli_query ($link, $getfee))
		$error = 'Error adding property details: ' .mysqli_error($link). " ";
		include 'error.html.php';

is the code i have to set the variable, I am sure it is a simple slip up on my part. $client is a $_session variable and fee is an integer if that has any effect.

all help greatly appreciated :wink:

TY SpacePheonix - I was getting so out of shape on how to query SQL, your advice worked perfectly, thank you!!!

Obviously i am very new to this, and each little step is another lesson learnt!

Onwards now till my next stumbling block!!!

Yes, I want $getfee to equal the MySQL result set, ie $getfee = 45 (or similar).

As $client is a session variable are you earlier on doing something like:


Have you started sessions with session_start() ?

$getfee is as the code stands the query which your using. In these two lines:

    $getfee = "select fee from client where name=' .$client. ' ";

    if (!mysqli_query ($link, $getfee))

replace $getfee with $sql

    $sql = "select fee from client where name=' .$client. ' ";

$result = mysqli_query ($link, $sql);

if ($result === false) {
// code to display error

$row = mysqli_fetch_array($result, MYSQLI_BOTH);

If your getting more then one fee then you’ll need to use a while loop with mysqli_fetch_array() to get each row in turn:

while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$getfee = "select fee from client where name='$client' ";

however it seems to constantly set the value of ‘$getfee’ to 0.

What do you mean by this? $getfee should contain the mysql result set if the query went ok, or FALSE if it threw an error.