hello friends,

I am try to get database values from while loop. but It gives me

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/empower.md/www/index_ujbee_file_uploard.php on line 32

here this is my code...

require "connect_ujbee_file_uploard.php";
require "todo.class_ujbee_file_uploard.php";
// Select all the todos, ordered by position:
$query = mysql_query("SELECT * FROM `ujbeeFile` ORDER BY `position` ASC");
$todos = array();
// Filling the $todos array with new ToDo objects:
while($row = mysql_fetch_assoc($query)){
	$todos[] = new ToDo($row);
}

but this is perfectly working at my local machine.I am using XAMPP version 2.5.8 but I put this script in to real server it give that error massage.

anybody can help me...? please....

Thank you
Umanda Jayo bandara

Change line 4 into:

$query = mysql_query("SELECT * FROM `ujbeeFile` ORDER BY `position` ASC") or die(mysql_error());

You will see that you do not have rights to login, the database does not exist, the table does not exist, or there is an error in your query.

try this.

$database = '';
$conn = mysql_pconnect(...conn info...);
mysql_select_db($database, $conn);
$query = "SELECT * FROM `ujbeeFile` ORDER BY `position` ASC";
$sql = mysql_query($query, $conn) or die(mysql_error());
while($row = mysql_fetch_assoc($sql)){
// the stuff
}

hope this helps :)

ok thank you all for your helps....

Member Avatar for rajarajan2017

Check your connection string which is relevant to your database server username and password.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.