chu-boi Posted June 8, 2009 Share Posted June 8, 2009 hi all, i currently develop locally with xampp i just started working with codeigniter, i downloaded and unzipped it to my PEAR folder in the php directory, i wasn't sure what to set my base_url to, so i set it to the directory where i keep all the php files i write for my webpages. I was following the tutorial on controllers found on the codeigniter website, I did every thing it said but when i try to view the page on the local server i get this error message "Fatal error: Class 'Controller' not found in C:\(the directory where i have my php files saved) on line 2 the code from the tutorial is <?php class Blog extends Controller{ function index(){ echo 'Hello World!'; } } ?> if the class was located it is supposed to display 'Hello World' does anybody have any suggestions on how to get codeigniter to locate and load my classes thanks Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/ Share on other sites More sharing options...
gevans Posted June 8, 2009 Share Posted June 8, 2009 Your base url should be set using the http protocol so, http://localhost/path-to-your-installation/ Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-851776 Share on other sites More sharing options...
chu-boi Posted June 8, 2009 Author Share Posted June 8, 2009 hey, thanks for the reply, I tried setting the base url as you said and i still get same message when i try to load the page. do you know any other way i could check if my codeigniter installation was done correctly, i.e if the stuff works :-\ Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-851852 Share on other sites More sharing options...
gevans Posted June 9, 2009 Share Posted June 9, 2009 I couldn't remmeber correctly if you actually need to do anything, it's been a while. But you don't Download a fresh copy, unzip it, load up index.php and you will see a welcome screen of type using a view and a controller. Make sure you get that page, then refresh it as you do your configs, one at a time, though you can get away without doing the configurations. Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-852144 Share on other sites More sharing options...
chu-boi Posted June 9, 2009 Author Share Posted June 9, 2009 Once again thanks for the reply, I did what you said and it works fine! I'll try and read the user guide to find out what how much i can do with codeigniter. Thanks for all the tips Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-852572 Share on other sites More sharing options...
gevans Posted June 9, 2009 Share Posted June 9, 2009 You should find taht following the tutorials is very easy from here. and shouldn't cause you any issues. I did them myself once upon a time. If you're unsure of something, just make one change at a time Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-852573 Share on other sites More sharing options...
chu-boi Posted June 11, 2009 Author Share Posted June 11, 2009 Hey, I've got another quick question, i was reading the tutorial on using form_helpers and form_validator to validate user inputs, I followed the instructions and attempted to recreate it, i'm able to load the view with the forms, but when i try to submit the form, i get redirected to a google error page with this message: DNS error - cannot find server Oops! This link appears to be broken. the tutorial says using the form_helper feature 'form_open()', sends the form to your base url, I still think I maybe i didn't set my base url. do you have any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-853751 Share on other sites More sharing options...
chu-boi Posted July 1, 2009 Author Share Posted July 1, 2009 Hey i figured out what was wrong, it had to do with the base url settings, i fixed it and everything is working fine. I have been working with mysql, i can output records from the database using SELECT. Right now i can only output all records or just one. I'm trying to figure out how to output data based on a number, say user id number, this way i can output only the first 10 records or the first 15. Any help will be greatly appreciated Thanks! for everything Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-867170 Share on other sites More sharing options...
wildteen88 Posted July 1, 2009 Share Posted July 1, 2009 Isnt that just basic SQL? SELECT * FROM users LIMIT 10 The above translated into Active Record $query = $this->db->get('users_table', 10); Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-867321 Share on other sites More sharing options...
chu-boi Posted August 13, 2009 Author Share Posted August 13, 2009 Hey thanks for the tip, I've got another problem that's more complicated. I'm using AJAX to return a database query to the same page as the user input form. It returns the correct record when the user types a value that matches, say username. I want it to return a custom error message when the user types in a value that doesn't match or doesn't type anything in. This is the php script i'm using: <?php $con = mysql_connect("conection_data"); if (!$con){ die('Could not connect: ' . mysql_error()); } mySQL_select_db("database", $con); $retrieve = $_GET['value']; //escape user input $retrieve = mySQL_real_escape_string($retrieve); if($retrieve != ""){ $query = "SELECT * FROM column_name WHERE userName = '$retrieve'"; if (is_numeric($retrieve)) $query .= " OR userID = $retrieve "; }else{ //the error message for NULL input values echo "please enter a username or rank"; } //excute query $qry_result = mySQL_query($query) or die(mySQL_error()); //build result string //use the while loop to pull out table records while ($row = mySQL_fetch_assoc($qry_result)) { $retrieve = $_GET['value']; $retrieve = mySQL_real_escape_string($retrieve); if($row['userName'] == $retrieve || $row['userID'] == $retrieve) { $display_string = "<table border='1' border='#444000'>"; $display_string .= "<tr>"; $display_string .= "<th> username </th>"; $display_string .= "<th> rank </th>"; $display_string .= "</tr>"; $display_string .="<tr>"; $display_string .="<td>" . $row['userName'] . "</td>"; $display_string .="<td>" . $row['userID'] . "</td>"; $display_string .= "</table>"; echo $display_string; }else{ //the error message for input values that don't match echo "username or rank does not match records"; } } ?> I changed the connection details for security reasons. Do you notice anything wrong? currently when the user doesn't type anything in the form, the error message that is returned is "please enter a username or rankQuery was empty" i'm not sure where the Query was empty part came from but I would like to remove it if the user types a value that doesn't match, nothing is returned. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/#findComment-897529 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.