SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Getting Rows From A Session ID

    Hi,

    I have created a session id but I am struggling to echo an information from database. Does anyone have any suggestions on what I can do.

    In all I am trying to update the members profile by using the members id.

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,120
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Post your code? Hard to tell where you are going wrong when we can't see what you are working with...

  3. #3
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sorted it, well at least I think I have.

    I just couldn't pull the id from the DB unit I did this:

    Code:
    $id = $_SESSION['userID'];


    Code:
    		
    <?php	
    	 $id = $_SESSION['userID'];
    	
    
    
    	
    function mysql_real_escape_array($t)
    {
        return array_map("mysql_real_escape_string",$t);
    }
    
    function trim_array($ar)
    {
        return array_map("trim",$ar);
    }
    
    if(isset($_POST['form_id']))
    {
        $_POST = mysql_real_escape_array($_POST);
        $_POST = trim_array($_POST);
        $error = "";
    
        if(!isset($_POST['category']) || empty($_POST['category'])) {
            $error = "Please select a category.";
    
        }
    
        if(!isset($_POST['website']) || empty($_POST['website'])) {
            $error.= " Please enter a Website Domain.";
        }
    
        if(!isset($_POST['company']) || empty($_POST['company'])) {
            $error.= " Please enter a Company Name.";
        }
    
        if(!isset($_POST['building']) || empty($_POST['building'])) {
            $error.= " Please enter a Building Name or Number.";
        }
    
        if(!isset($_POST['streetname']) || empty($_POST['streetname'])) {
            $error.= " Please enter a Street Name.";
        }
    	
    	    if(!isset($_POST['town']) || empty($_POST['town'])) {
            $error.= " Please enter your Town.";
        }
    
        if(!isset($_POST['state']) || empty($_POST['state'])) {
            $error.= " Please enter a State.";
        }
    
        if(!isset($_POST['postcode']) || empty($_POST['postcode'])) {
            $error.= " Please enter a Zip Code/Post Code.";
        }
    
        if(!isset($_POST['country']) || empty($_POST['country'])) {
            $error.= " Please select your country.";
        }
    
        if(!isset($_POST['aboutcompany']) || empty($_POST['aboutcompany'])) {
            $error.= " Please enter details about your company.";
        }
    
        if($error == "")
        {
            $sql = "
            UPDATE
                users
            SET
                category = '".$_POST['category']."',
    		linkcategory = '".str_replace(' ', '-',strtolower($_POST['category']))."',
                firstname = '".$_POST['firstname']."',
                surname = '".$_POST['surname']."',
                email = '".$_POST['email']."',
                website = '".$_POST['website']."',
                company = '".$_POST['company']."',
                building = '".$_POST['building']."',
                streetname = '".$_POST['streetname']."',
    			town = '".$_POST['town']."',
                state = '".$_POST['state']."',
                postcode = '".$_POST['postcode']."',
                aboutcompany = '".$_POST['aboutcompany']."',
    			country = '".$_POST['country']."'
    			         WHERE 
    			id=$id";
    
            $result = mysql_query($sql) or die("An error occurred ".mysql_error());
    
        }
    
    }
    
    ?>

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,180
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    print_r(); on your array will help you debug


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
  •