Welcome Guest, Not a member yet? Register   Sign In
Query returning no results?
#11

[eluser]InsiteFX[/eluser]
[quote author="Dennis Rasmussen" date="1290003006"]InsiteFX, don't be a douche... really.
And I'm sure D13 also hits the report button once in a while - like the rest of us.

For anyone reading this topic later and having trouble themselves, I believe the OP found out to always load the database (based on the info we got).[/quote]

douche?

Not really! but if you check the forum topics you will see that he does that to anyone
that makes a simple mistake...

Look at the times on my posts, but that's it no more!

Goodbye

InsiteFX
#12

[eluser]Dennis Rasmussen[/eluser]
But if someone makes a mistake and nobody points it out, then others will do as well... duh?!
#13

[eluser]matt.asbury[/eluser]
Try:
Code:
var_dump($query->num_rows);
instead of:
Code:
echo $query->num_rows;
Just to make sure that the error is with results not being returned rather than not being output correctly. You should get something on the browser even if it's just bool(false).
#14

[eluser]Xabi87[/eluser]
I tried using the testDB controller (with a query that definitely returns rows), with no models involved, but same problem, no output.

CroNiX - yes I am autoloading the database library, and I also tried manually loading it in the constructor.

Code:
var_dump( $query->num_rows() );
prints out NULL

Does this NULL give any clues to what's going wrong?

Thanks for all the responses!
#15

[eluser]matt.asbury[/eluser]
Honestly Xabi, I'm not too sure where to go with this now. With all the details you have given us, the database should be returning something. You could try simplifying the query further:
Code:
SELECT * FROM products
If this does nothing then I'm not too sure what to test next. As long as you are getting results from the other tool you are using, you can rule out problems with the database. You could try commenting out this code and do a manual connection to the database to run a query using classic PHP:
Code:
$link = mysql_connect("host", "user", "password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM tablename", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

mysql_close($link);
#16

[eluser]veritascs[/eluser]
Well, CI is connecting to your database; otherwise, it would throw errors like:

Code:
Unable to select the specified database: mydb
//or
Unable to connect to your database server using the provided settings.

In your index.php, do you have:
Code:
error_reporting(E_ALL);

I'm not really an expert Sad

I'd try breaking it on purpose from the beginning, say at the database connection (ie add an extra char to $hostname). Then fix it and break the next piece until you get to the issue you are having now. That should at least tell you where the error is.

Edit: Your first post has debug=FALSE...make sure that is TRUE.
#17

[eluser]Xabi87[/eluser]
Thanks both for your help, I've established (using classic PHP) that it's a MySql connection error:

Code:
Could not connect: mysqlnd cannot connect to MySQL 4.1+ using old authentication

It seems MySql was upgraded on my server since my last successful CI project!

Thank you for all responses.

Xabi




Theme © iAndrew 2016 - Forum software by © MyBB