Link to home
Start Free TrialLog in
Avatar of pingeyeg
pingeyeg

asked on

Update statement causing the Resource #3 to display

I have created an update statement, but for some reason I am getting the Resource #3 display when I don't feel I should be.  I know that this message is wanting the mysql_fetch_array function, but I don't feel I need it.


$conn = mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("353322_photos") or die(mysql_error());
 
if($_POST['Submit']) {
	$id = $_POST['ID'];
	$pA = $_POST['packageA'];
	$pB = $_POST['packageB'];
	$pC = $_POST['packageC'];
	$printA = $_POST['8x10'];
	$printB = $_POST['5x7'];
	$printC = $_POST['4x6'];
	$wallet = $_POST['wallet'];
	
		$update = "update pricing set packageA = '$pA', packageB = '$pB', packageC = '$pC', 8x10 = '$printA', 5x7 = '$printB', 4x6 = '$printC', wallet = '$wallet' where ID = '$id'";
		$result = mysql_query($update) or die(mysql_error());
		
		if($_POST['Submit']) {
			$result = "Your pricing changes have now been made and have reflected in the cart.";
		} else {
			$result = "There seems to have been an issue with your update.  Please contact <a href=\"mailto:brannon@goodboyweb.com\">Goodboy</a> for further assistance.";
		}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnpccd
johnpccd

notice the column names in the query are put inside quotes
:)
Avatar of pingeyeg

ASKER

I'm still getting: Resource id #3
Is there more code? What I gave is the "fix" to what you posted.
I must not have refreshed the page correctly because now I get a new error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''packageA' = '20.00', 'packageB' = '24.00', 'packageC' = '18.00', '8x10' = '12.0' at line 1

There is more code on the page, but the other code doesn't have anything to do with this update statement.
if($_POST['Submit']) {
      $id = $_POST['ID'];
      $pA = $_POST['packageA'];
      $pB = $_POST['packageB'];
      $pC = $_POST['packageC'];
      $printA = $_POST['8x10'];
      $printB = $_POST['5x7'];
      $printC = $_POST['4x6'];
      $wallet = $_POST['wallet'];
      
            $update = "update pricing set 'packageA' = '$pA', 'packageB' = '$pB', 'packageC' = '$pC', '8x10' = '$printA', '5x7' = '$printB', '4x6' = '$printC', 'wallet' = '$wallet' where ID = '$id'";
            mysql_query($update) or die(mysql_error());
            
            if(mysql_affected_rows() > 0) {
                  $result = "Your pricing changes have now been made and have reflected in the cart.";
            } else {
                  $result = "There seems to have been an issue with your update.  Please contact <a href=\"mailto:email.com\">Company</a> for further assistance.";
            }
}

Open in new window

You have apostrophes around your fields names:
...'packageB' =...

I do NOT. You need backtick ( the character underneath the ~ character ), not apostrophe. Copy and paste from my post.
Still getting the same thing.  Resource id #3
What's weird is the fact that the page IS updating yet I am still getting Resource id #3 instead of the $result.
Well I finally figured it out.  I was already using that variable $result as my result for another area so apparently it was getting confused.