Jump to content

[SOLVED] small function problem [assistance would be great]


UziLok

Recommended Posts

hello, well as you can see here:

 

got my function,

function readUsers($fname, $uname, $email, $phone) {
    $sql = sprintf(" SELECT * FROM `crud_` WHERE `id` = '%s'", 
    mysql_real_escape_string($id));
    $res = @mysql_query($sql) or die(mysql_error());
    if ($res) {
      $output = '';
        while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
            $output .= "First Name :{$row['fname']} <br>" . "username :{$row['uname']} <br>" . "email : :{$row['email']} <br>" . "phone :{$row['phone']} <br>";
        }
      return $output;
    }else{
      return false;
    }
}  

 

and then to output it in a page called showusers i have like this

<?php
include "crud_functions.php";
connect($conn);
selectDB($conn, $dbname);


//list users
$listUsers = readUsers($fname, $uname, $email, $phone);
echo $listUsers;


?>

 

and the problem is that showusers turns blank..

so i need some help to understand why, might have missed something in the code

as i tend to code fast when i am on a roll :P

 

Thank you for the help

in advance!

???

 

 

Link to comment
Share on other sites

code update!.

 

function readUsers($id) {
    $sql = sprintf("SELECT * FROM `crud_` WHERE `id` = %d", 
    (int)$id);
    $res = @mysql_query($sql) or die(mysql_error());
    if ($res) {
      $output = '';
        while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
            $output .= "First Name :{$row['fname']} <br>" . "username :{$row['uname']} <br>" . "email : :{$row['email']} <br>" . "phone :{$row['phone']} <br>";
        }
      return $output;
    }else{
      return false;
    }
} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.