Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/161407-help-with-using-codeigniter/
Share on other sites

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 :-\

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.

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?

  • 3 weeks later...

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

  • 1 month later...

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?

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.