retrieve data from db |
[eluser]HugoA[/eluser]
Hi! I'm trying to retrieve all the data store in a table. To do this i configure the database.php file like this Code: $db['default']['hostname'] = "localhost"; i add to the autoload.php file this line Code: $autoload['libraries'] = array('database'); this is mi model Code: <?php this is the controller Code: <?php and this is the view Code: <html> According to this code I'm expecting to see all the records i have in the table "user" but i don't see anything in the page, only a white page, i cant see even the message "La vista fue cargada". If i remove all the things that have something to do with working with the data base i can see "La vista fue cargada" in the page. Any ideas? this is the first time i work with CodeIgniter. Thanks for the help.
[eluser]wowdezign[/eluser]
Quote: looks wrong. do you want? Code: <?php print_r($records); ?>
[eluser]HugoA[/eluser]
You are right, that line is wrong but the problem persist. Could be something with the autoload.php file? if i replace this line $autoload['libraries'] = array('database'); with this $autoload['libraries'] = array(); at least i can see an error Quote:A PHP Error was encountered
[eluser]wowdezign[/eluser]
That error is telling you that you didn't load the database configuration. Which is, in fact, true when you delete that line of code.
[eluser]wowdezign[/eluser]
Try: Code: <?php And: Code: <?php and see if that helps.
[eluser]HugoA[/eluser]
how can i know if there is an error trying to connect to the data base? because that blank page is telling me nothing at all. Mi project is in this route C:\Aplicaciones\site there i have this folders: system user_guide application and this files: index.php license.txt in the httpd.conf file i have DocumentRoot "C:\Aplicaciones\site" and i see the page with this url http://localhost/index.php/site
[eluser]HugoA[/eluser]
I replace mi code with yours and the problem persist.
[eluser]wowdezign[/eluser]
Did you set your default controller to site? in the config folder in the routes file: Code: $route['default_controller'] = "site"; However, that probably isn't it either, if you are getting a page when you don't call the db. I would double check my database user name pw and db name settings because it looks like everything else is correct from what you've said above.
[eluser]2think[/eluser]
HugoA, You have one too many } in your code. Take out the last one. Hope this helps, you seem to be right otherwise
[eluser]jmadsen[/eluser]
HugoA, I think your cod eshould work fine - I took it without making any changes (2think - I don't see any } issues. Where are you looking? ) and it runs fine for me, against my own user table. Check in your index.php file for the line: error_reporting(E_ALL); If it doesn't say "E_ALL", change it to do so. That might at least help us get an error message so we can tell you what comes next. My guess is that you have a problem with your model (site_model.php). Check that it 1) is in the correct folder (system/application/models/) and 2) that it is named "site_model.php" (ALL SMALL LETTERS! NOT "Site_model.php") |
Welcome Guest, Not a member yet? Register Sign In |