Query won't display anything

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Query won't display anything

Post by klevis miho »

My problem is that I have a php script to do a SELECT query, but the script don't display anything (on an online serve).

But when I run this script in my localhost it displays the rows that I want.

Any ideas?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Query won't display anything

Post by califdon »

klevis miho wrote:Any ideas?
Not without seeing your script and your query.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Query won't display anything

Post by superdezign »

Your server's database is different than your local, or your query is corrupted. Give us your table structure and your query.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Query won't display anything

Post by klevis miho »

Here is my php code:

Code: Select all

<?php
$hostname = 'localhost';
$username = 'test';
$password = 'test';
$database = 'test';
 
mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
 
$sql = "SELECT * FROM jos_users";
$query = mysql_query($sql) or die(mysql_error());
 
 
while($row = mysql_fetch_array($query)) {
echo $row['name'];
}
 
?>
The database table is a joomla table called jos_users
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Query won't display anything

Post by superdezign »

And what output are you getting...?
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Query won't display anything

Post by klevis miho »

Online nothing, at my localhost pc the output is the desired result
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Query won't display anything

Post by superdezign »

Try echoing "Hello" at the end of the script to see if that prints out. If not, there is an error in your script (database connection, possibly) and your error_reporting or display_errors is turned off.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Query won't display anything

Post by klevis miho »

The script is ok as I said, on my pc it works fine, but online it wont
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Query won't display anything

Post by superdezign »

Obviously, the script is not okay.

Your local server and your online server likely have different settings. What I am trying to get you to do is to figure out which settings are different and fix your code to conform to the settings.
Post Reply