SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems Registering Values into Database

    I'm trying to do a simple register script using a class to handle all of the scripting.

    Problem is the data isn't getting entered into the database and there are no PHP errors being produced so i am unsure where the problem is occuring. If anyone could give me some debugging tips that would be great.

    http://www.creativebubbles.co.uk/demo6/admin/upload.php

    PHP Code:
    <?php
    session_start
    ();
    include(
    '../scripts/upload.class.php');

    $uploader = new Upload();

    $streetAddress $_POST['streetAddress'];
    $town $_POST['town'];
    $city $_POST['city'];
    $postcode $_POST['postcode'];
    $propertyDescription $_POST['propertyDescription'];
    $propertyRent $_POST['propertyRent'];

    $main_image $_FILES['mainImage']['tmp_name'];
    $main_image_name $_FILES['mainImage']['name'];
    $main_image_size $_FILES['mainImage']['size'];
    $main_image_type $_FILES['mainImage']['type'];
    $main_image_error $_FILES['mainImage']['error'];    

    //echo $main_image_name;
    //echo $town;

    $uploader->registerProperty($streetAddress$town$city$postcode$propertyDescription$propertyRent$main_image_name);


    ?>
    PHP Code:
    <?php
    require_once('config.php');

    //Class is for uplaoding files and registering properties into the database

    class Upload

    {
        private 
    $mMysqli;
        
        
    //constructor opens database connection
        
        
    function __construct() {
        
        
    $this->mMysqli = new mysqli(DB_HOSTDB_USERDB_PASSWORDDB_DATABASE);
        
        }
        
        
    //destructor closes database connection
        
        
    function __destruct() {
        
        
    $this->mMysqli->close();
        
        }
        
        
        public function 
    registerProperty($address_line_one$town$city$postcode$description$rent$main_image)
        {
        
        
    $uploadFileLinkImageOne 'http://www.creativebubbles.co.uk/demo6/images/properties/';    
        
        
    //check all values have been entered
        
        
        //check the image is the correct size
        
        
        //upload the image    
        
        
        //insert into database
        
    $query $this->mMysqli->query("INSERT into properties VALUES(NULL, '$address_line_one', '$town', '$postcode', '$description', '$rent', '$uploadFileLinkImageOne', NULL, NULL)");
            
        }
        
        
        
        
        private function 
    uploadImage($value)
        {
        
        
        
        }
        
    }

    ?>

  2. #2
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you using mysql_error() report?

    I think you must have the fields in your mysql query like this for example:

    $sql = "INSERT INTO my_table(id, name, address) values('$id', '$name', '$address');

    Check this out for information, there are 3 ways to use Insert it looks like:
    http://dev.mysql.com/doc/refman/5.0/en/insert.html


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •