Query won't display anything
Moderator: General Moderators
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Query won't display anything
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?
But when I run this script in my localhost it displays the rows that I want.
Any ideas?
Re: Query won't display anything
Not without seeing your script and your query.klevis miho wrote:Any ideas?
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Query won't display anything
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
Here is my php code:
The database table is a joomla table called jos_users
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'];
}
?>- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Query won't display anything
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
Online nothing, at my localhost pc the output is the desired result
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Query won't display anything
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
The script is ok as I said, on my pc it works fine, but online it wont
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Query won't display anything
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.
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.