0

i have a problem with php. I write the following code and it returns blank

<?php
                $query = mysql_query("SELECT * FROM users");
                $result = $database->sql_query($query);                         
                while ($dr = $database->sql_fetchrow($result))
                {
                    echo $dr['uid'];
                }
                $database->sql_freeresult($result)

                ?>

i call this
include_once 'includes/db.php';

and on db.php.
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());

5
Contributors
13
Replies
46
Views
3 Years
Discussion Span
Last Post by diafol
0

Shouldn't line 2 be:

$query = "SELECT * FROM users";

(without the mysql_query part)?

0

`

define('DB_DATABASE', 'wall');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());

`

you mean this? why?

0

Are you sure your while loop is working then?

Try testing this and check the result:

while(...){
    echo "testing";
    echo $var['id'];
}

And try this too: `mysql_query(...) or die(mysql_error())

What you have is a hidden problem and you need to test every possible thing to indentify a cause.

0

yes they are

define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'Pass');
define('DB_DATABASE', 'simon');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());

no its not working

$query = "SELECT * FROM users";
                $database->sql_query($query);                       
                while ($dr = $database->sql_fetchrow($result))
                {
                    echo 'testing';
                    echo $dr['uid'];
                }
                $database->sql_freeresult($result)
0

what should i do to identify a hidden problem? tried $query = "SELECT * FROM users" or die(mysql_error()); too

0

Also I just noticed your database name in your first post is 'wall' but now it has changed to 'simon' that might also be causing a problem.

0

My only other hint is I don't know what you are using... I did a quick google search on sql_fetchrow()

I was about to raise the same point. There seems to be some confusion here. A basic mysql connection - WHICH IS DEPRECATED BTW and then the use of a user-defined db object. In addition, there seems to be some reticence with regard to providing the entire code required. Oh - useful descriptive title for the thread too :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.