SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    update table command with php script

    Hey,

    Im trying to do a mysql update table command through a php script but im having problems. The first column to be updated is an "INT" column and this updates fine but the other two columns are "VARCHAR" columns. Is their something i have to do differently to update a VARCHAR field or something???

    When i try this code it updates "private_group" to the new value (10) but just leaves the other two fields blank in the mysql table.

    Thanks

    Code:
    		$sql = "UPDATE apple_users
    		SET private_group = 10,
    		private_group_name = skerries,
    		private_group_password = klsokp
    		WHERE ".$_SESSION['user_id']." = user_id
    		";
    		$results = mysql_query($sql)
    			or die(mysql_error());

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you aren't checking your mysql errors, are you

    try copy/paste that query directly into a mysql front end utility or your mysql command line

    tip: if you have problems getting a mysql query running in php, make sure you test it in mysql first
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    $sql = "UPDATE apple_users
    		SET private_group = 10,
    		private_group_name = 'skerries',
    		private_group_password = 'klsokp'
    		WHERE ".$_SESSION['user_id']." = user_id
    		";

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    awwww.... sb- you're no fun! rudy and i love to torture people who don't error-check their queries outside the host language!


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
  •