Page 1 of 1
Query won't display anything
Posted: Wed Nov 18, 2009 10:51 am
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?
Re: Query won't display anything
Posted: Wed Nov 18, 2009 12:51 pm
by califdon
klevis miho wrote:Any ideas?
Not without seeing your script and your query.
Re: Query won't display anything
Posted: Wed Nov 18, 2009 12:54 pm
by superdezign
Your server's database is different than your local, or your query is corrupted. Give us your table structure and your query.
Re: Query won't display anything
Posted: Wed Nov 18, 2009 1:05 pm
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
Re: Query won't display anything
Posted: Tue Nov 24, 2009 7:58 am
by superdezign
And what output are you getting...?
Re: Query won't display anything
Posted: Tue Nov 24, 2009 8:03 am
by klevis miho
Online nothing, at my localhost pc the output is the desired result
Re: Query won't display anything
Posted: Tue Nov 24, 2009 8:10 am
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.
Re: Query won't display anything
Posted: Tue Nov 24, 2009 8:12 am
by klevis miho
The script is ok as I said, on my pc it works fine, but online it wont
Re: Query won't display anything
Posted: Tue Nov 24, 2009 8:17 am
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.