Jump to content

ReeceSayer

Members
  • Posts

    97
  • Joined

  • Last visited

Posts posted by ReeceSayer

  1. As in the title - my PHP.ini doesn't seem to be working - I did move from a WAMP setup to an LAMP setup but i changed the files in my ini to reflect the different directories.

     

    I have the following set in my php.ini:

    include_path = ".:/var/sites/t/testing.indigoonline.co.uk/public_html/php"

    However, when i try to require the file i get the following:

    Warning: require_once(required.php) [function.require-once]: failed to open stream: No such file or directory in /var/sites/t/testing.indigoonline.co.uk/public_html/admin/index.html on line 4
    
    Fatal error: require_once() [function.require]: Failed opening required 'required.php' (include_path='.:/usr/local/lib/php') in /var/sites/t/testing.indigoonline.co.uk/public_html/admin/index.html on line 4

    It seems that the php.ini isn't having an effect - anyone have any ideas please? I know i'm probably just missing something really simple.

     

    Thanks

     

     

  2. Yes - I have but he wants to charge an additional fee - I'd prefer to solve this myself.

     

    I set the include_path in php.ini to the php folder which seemed to resolve most issues.

     

    I can see everything working perfectly on the front end and can now access the login page on the back end but i can't login.

     

    I'll ask the developer again to see what they can do.

     

    Thanks

  3. Hi,

     

    We've recently purchased a website at work and have it up and running on the previous owners server at a cost, we can't have FTP access to this for some reason so attempting any changes is a pain.

     

    I've got the files from the owner and am trying to set them up on WAMP to ensure that i can move over and setup / develop when needed.

     

    I received 3 files which i'll list below:

     

    • SQL file
    • SITENAME.com Folder
    • PHP Folder

    Initially i thought that i should merge the php and sitename folders together (which i did) - this allowed the majority of things to work on the front end of the site but then when i went to go to the admin directory /admin/ i received a tonne of errors about missing filepaths etc. trying to resolve appears to lead me around 30 different files which i need to change a require_once function on.

     

    I'm thinking it's got to be easier than this but obviously i'm not entirely sure what i'm supposed to do with said folders?

     

    Anyone have any ideas? (and apologies if this isn't in the correct category.)

     

    Thanks,

     

    Reece

  4. This will get the details of those records with duplicated jobrefs (if that is what you are after)

     

    SELECT title, jobref, location, description, salary, apply
    FROM vacancy
    INNER JOIN (
     SELECT jobref, COUNT(*) as tot
     FROM vacancy
     GROUP BY jobref
     HAVING tot > 1
    ) as x USING (jobref)
    ORDER BY jobref

     

    Thanks works brilliantly, I've just used IGNORE when importing the data and set the jobrefs column to unique which also seems to do the job (i'm importing a different data-set every day and didn't want duplicates).

     

    Thanks again

  5. Hi,

     

    I'm trying to remove duplicates from my database table (vacancy).

     

    Currently using the following SQL statement:

     

    SELECT title, jobref, location, description, salary, apply FROM vacancy WHERE jobref IN (SELECT DISTINCT jobref FROM vacancy)
    

     

    However, this still brings back the duplicates, each statement works on its own (I.e. DISTINCT brings back unique values for that column, and SELECT * brings back all rows & Columns) so i'm not entirely sure why it's not working.

     

    If there's a simpler way of doing this i'm open to trying it out.

     

    Cheers

  6. You apparently copy/pasted the code from some rich-text/formatted source.

     

    Please go back and copy/paste just the plain text from your programming editor.

     

    It should have changed now i've edited the post, i copied it straight from Notepad++, not sure what the problem was.

     

    Thanks

  7. Hi All,

     

    I'm trying to set up some code to download a CSV file from an ftp host and then i want to do something with it.

     

    However, i can't quite get the code to work. I get the following error:

     

    Warning: ftp_get() [function.ftp-get]: Failed to open file. in /home/rsyr/restofthedirectories/ on line 8

     

    Here's the code, excuse the messiness:

     

    <?php
    $today = date("Y-m-d");
    $conn = ftp_connect("ftp.zois.co.uk") or die("Could not connect");
    ftp_login($conn,"anonymous","");
    echo "JCP-scrape-". $today;
    echo ftp_get($conn,"JCP-scrape-18-10-2012.csv", "/pub/jcp/JCP-scrape-18-10-2012.csv",  FTP_ASCII);
    ftp_close($conn);
    //sql code to move data from holding table to vacancy table
    //INSERT INTO vacancy (title, jobref, location, description, apply) SELECT title, reference, location, description, apply FROM holdingtable
    //truncate holdingtable
    //Holding table should then be truncated
    ?>
    

     

    Thanks

  8. Yeah i understand a little better now thanks.

     

    Only one way i can think of doing it at the minute.

     

    Possibly wrap those if statements in another to check that both the user and pass GET variables are set before going into that verification.

     

    Like this:

    <?php
    session_start();
        define('DB_HOST', 'localhost');
        define('DB_USER', 'mydbusername');
        define('DB_PASSWORD', 'mydbpass');
        define('DB_DATABASE', 'mydbname');
           
        $errmsg_arr = array();
        $errflag = false;
    
        $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
        if(!$link) {
      die('Failed to connect to server: ' . mysql_error());
        }
    
        $db = mysql_select_db(DB_DATABASE);
        if(!$db) {
    
    die("Unable to select database");
        }
    
       function clean($var){
    
    return mysql_real_escape_string(strip_tags($var));
        }
        $image = clean($_GET['image']);
        $strings = clean($_GET['strings']);
        $username = clean($_GET['user']);
        $pass = clean($_GET['pass']);
    
    if (isset($_GET['user'])) && (isset($_GET['pass'])) {
        if($username == '' && $pass) {
      $errmsg_arr[] = 'username are missing';
      $errflag = true;
         }elseif($username && $pass =='') {
      $errmsg_arr[] = 'PASSWORD are missing';
      $errflag = true;
        }
        if($username == '' && $pass == '') {
      $errmsg_arr[] = 'username or password missing';
      $errflag = true;
        }
    }
        if($errflag) {
      $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
      echo implode('<br />',$errmsg_arr);
       }
       else {
    
    
    $insert = array();
    if(isset($_GET['image'])) {
        $insert[] = 'image = \'' . clean($_GET['image']) . '\'';
    }
    if(isset($_GET['strings'])) {
        $insert[] = 'strings = \'' . clean($_GET['strings']) . '\'';
    }
    if(isset($_GET['user'])) {
        $insert[] = 'user = \'' . clean($_GET['user']) .'\'';
    }
    if(isset($_GET['pass'])) {
        $insert[] = 'pass = \'' . clean($_GET['pass']) . '\'';
    }
    
    
    
    if (count($insert)>0) {
       $names = implode(',',$insert);
    
    $required_fields = array('image', 'strings', 'user');
    
    if($image && $strings && $username) {
      echo "working 1";
    } elseif($username && $pass) {
      echo "working 2";
      }
    }
    }
    

     

    Not sure if it's good practice to do it that way but i'm still learning :)

  9. The else if statement is checking if your password is set from the GET in the URL.

     

    If you don't pass it in the URL it will throw that error.

     

    If you don't want people to see the password in the URL you could use POST instead.

     

    If you want to get rid of it remove the elseif or set the $errflag variable to false.

     

    Probably defies the point though.

     

    Not sure exactly what you're trying to accomplish, sorry if i've misunderstood.

  10. No sorry i didn't mean like that.

     

    However, If you haven't already solved the issue it appears to be this:

     

    if((!isset($_SESSION['id'])) || (!isset($_POST['callname'])) || (!isset($_SESSION['username'])) || (!isset($_SESSION['email'])) || (!isset($_SESSION['password'])))
    {
    unset($_SESSION['callname']);
    unset($_SESSION['username']);
    unset($_SESSION['email']);
    unset($_SESSION['password']);
    unset($_SESSION['id']);
    
    $loggedin = 0;
    }
    else
    {
    $loggedin = 1;
    }
    

     

    You're checking for a post value when you should be checking for your session value instead.

     

    I've just tested it and it works as you want i think.

  11. Okay.... Only one thing i can think of off the top of my head.

     

    You're echoing out the variables and it seems to be missing double quotes / single quotes (i'm not sure if this has to be done and i don't have the time to test at the minute.)

     

    Try it the way litebearer did in his example. That way we can rule that out 100%.

  12. if you're pulling the email addresses from a database you could use get. So instead of linking to the email address it links to: myscript.php?email=example@example.com

     

    then you'd do something like the following:

     

    <?php
    //this would get the email and make into a variable.
    $email = $_GET['email'];
    
    ?>
    

     

    Then you'd include the email script here and a probably a textarea box.

     

    Once you click submit it would send an email to that user.

  13. Try this.

     

    <?php
    
    include('config.php');
    
    //retrieve our data from POST
    $username = $_POST['username'];
    $pass1 = $_POST['pass1'];
    $pass2 = $_POST['pass2'];
    
    if($pass1 != $pass2) {
        header('Location: register_form.php');
    }
    
    if(strlen($username) > 30) {
        header('Location: register_form.php');
        }
    
    if (strlen($username) < 30 && $pass1 == $pass2){
        $hash = hash('sha256', $pass1);
    
    function createSalt()
    {
        $string = md5(uniqid(rand(), true));
        return substr($string, 0, 3);
    }
    
    $salt = createSalt();
    $hash = hash('sha256', $salt . $hash);
    //sanitize username
    $username = mysql_real_escape_string($username);
    $query = "INSERT INTO users (username, password, salt)
            VALUES ('$username' , '$hash' , '$salt')";
    mysql_query($query);
    mysql_close();
    
    echo 'You have been registered! You may now <a href=index.php>Log in</a>.';
    
    }
    else
    {
    
    echo '<center><form name=register action=register.php method=post>
    Username: <input type=text name=username maxlength=30><br>
    Password: <input type=password name=pass1><br>
    Password Again: <input type=password name=pass2><br>
    <input type=submit name=submit value=Submit>
    </form></center>';
    
    }
        ?>
    

     

    It's untested and may not work but there were a lot of tiny errors in the code.

     

    Added an if statement to check values are correct before submitting, you also need to check that the username doesn't already exist (unless you are allowing people with the same user name??)

     

    Just trying to help as i need the practice.

  14. I had a similar problem.

     

    Mine was when uploading a document and checking the database to see if it existed.

     

    There doesn't look to be any problem in your code and you say "... I’m getting the correct result which I’m expecting..."

     

    Just ensure you're passing the variables properly and you shouldn't have an issue.

  15. Hey, I'm trying to combine two of the tutorials i've been using and have gotten a little stuck.

     

    I create an online cart with pagination links however the links are sending me to a 404 error page.

     

    I've been playing around with it to try and get it to work but can't seem to see my problem so there might be things commented out.

     

    My default url is (http://example.com/tutorial/shop), the pagination is trying to reach http://example.com/tutorial/shop/4 (this depends on how many results i show on the first page)

     

    Controller (shop.php):

    <?php
    class Shop extends Controller {
    
    //included for pagination
        public function __construct() {
            parent:: __construct();
            $this->load->helper("url");
            $this->load->model("products_model");
            $this->load->library("pagination");
        }
    
    function index() {
    	//star pagination
    	$config = array();
            $config["base_url"] = base_url() . "shop";
            $config["total_rows"] = $this->products_model->record_count();
            $config["per_page"] = 4;
            $config["uri_segment"] = 3;
    
            $this->pagination->initialize($config);
    
            $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
            $data["products"] = $this->products_model->
                fetch_products($config["per_page"], $page);
            $data["links"] = $this->pagination->create_links();
    	//end of pagination
    
    	$this->load->model('Products_model');
    
    	//$data['products'] = $this->Products_model->get_all();
    
    	$this->load->view('products', $data);
    
    
    }
    
    function add() {
    
    	$this->load->model('Products_model');
    
    	$product = $this->Products_model->get($this->input->post('id'));
    
    	$insert = array(
    		'id' => $this->input->post('id'),
    		'qty' => 1,
    		'price' => $product->price,
    		'name' => $product->name
    	);
    	if ($product->option_name) {
    		$insert['options'] = array(
    			$product->option_name => $product->option_values[$this->input->post($product->option_name)]
    		);
    	}
    
    	$this->cart->insert($insert);
    
    	redirect('shop');
    
    }
    
    function remove($rowid) {
    
    	$this->cart->update(array(
    		'rowid' => $rowid,
    		'qty' => 0
    	));
    
    	redirect('shop');
    
    }
    
    }
    
    

     

    Model (product_model):

    <?php
    class Products_model extends Model {
    
        public function __construct() {
            parent::__construct();
        }
    
    
    function fetch_products($limit, $start) {
    //function get_all($limit, $start) {
        $this->db->limit($limit, $start);
    	$results = $this->db->get('products')->result();
    
    	foreach ($results as &$result) {
    
    		if ($result->option_values) {
    			$result->option_values = explode(',',$result->option_values);
    		}
    
    	}
    
    	return $results;
    
    }
    
    function get($id) {
    
    	$results = $this->db->get_where('products', array('id' => $id))->result();
    	$result = $results[0];
    
    	if ($result->option_values) {
    		$result->option_values = explode(',',$result->option_values);
    	}
    
    	return $result;
    }
    
    //attempt at implementing pagination class
    public function record_count() {
            return $this->db->count_all("products");
        }
    /*
    public function fetch_products($limit, $start) {
            $this->db->limit($limit, $start);
            $query = $this->db->get('products');
            if ($query->num_rows() > 0) {
                foreach ($query->result() as $row) {
                    $result[] = $row;
    
              }
                return $result;
            }
            return false;
       }
    */
    }
    
    

     

    Any help or points in the right direction would be awesome!

     

    Thanks

  16. My first time using CI and i've run into a snag at the second hurdle (even though it seems quite common from my online searches)

     

    I'm completing the second tutorial from the user guide (http://codeigniter.com/user_guide/tutorial/news_section.html)

     

    The issue i'm having is similar to that i've seen posted on the CI forums but i'm not seeing any actual response on there.

     

    Model (news_model.php):

    <?php
    class News_model extends CI_Model {
    
    public function __construct() {
    
      $this->load->database();
    }
    
    public function get_news($slug = FALSE) {
    
      if ($slug === FALSE) {
       $query = $this->db->get('news');
       return $query->result_array();
      }
       
      //this seems to be causing an issue
      $query = $this->db->get_where('news', array('slug' => $slug));
      return $query->row_array();
    }
    
    }
    

     

    Controller (news.php):

    <?php
    class News extends CI_Controller {
    
      public function __construct()
      {
       parent::__construct();
       $this->load->model('news_model');
      }
    
      public function index()
      {
       $data['news'] = $this->news_model->get_news();
       $data['title'] = 'News archive';
      
       $this->load->view('templates/header', $data);
       $this->load->view('news/index', $data);
       $this->load->view('templates/footer');
      }
    
    public function view($slug)
    {
        $data['news_item'] = $this->news_model->get_news($slug);
    
        if (empty($data['news_item']))
        {
            show_404();
        }
    
        $data['title'] = $data['news_item']['title'];
    
        $this->load->view('templates/header', $data);
        $this->load->view('news/view', $data);
        $this->load->view('templates/footer');
    }
    } 
    

     

    I commented in the model where i think is causing an issue but i'm not sure why. Obviously i'm getting thrown into the 404 error because the data news item is empty but it shouldn't be.

     

    The initial index page works and my routes are all defined as they are in the tutorial. I previously replaced the  show_404() with an exit('this is the error'); and it then shows this error.

     

    Also, my base url is defined as this: http://mysite/projects/framework which is where the CI installation is.

     

    Apologies if this has been answered before but when searching the forum i get an "Unable to access the search daemon" error.

     

    Cheers

  17. Hi,

     

    Thanks for the quick replies. I thought it was bad which is why i thought i'd post on here to find a better way of doing it but it's the only immediate way i could think of getting the results.

     

    I've just had a quick look and it looks like both of your solutions would work.

     

    Also yes the dropdown is always hardcoded.

     

    I'll try and implement your solutions and see which works best.

     

    Thanks a lot!

  18. If you had this code on your index page it would forward to login.php straight away.

     

    	session_start();
                    //if not all of the variables are set forward to the login page
    	if(!isset($_SESSION['email']) || !isset($_SESSION['sid']) || !isset($_SESSION['ip']) || !isset($_SESSION['id']) || $_SESSION['adminid'] == 1) {
    	header("Location: login.php");
    	exit();
    	}
    

     

    If you meant you type in the base url and it returns you the log in url you would already have to have that in your database.

     

    Seems like an odd piece of code though.

     

     

     

×
×
  • 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.