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

PHP

Avatar of undefined
Last Comment
pingeyeg

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
hielo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
johnpccd

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

I'm still getting: Resource id #3
hielo

Is there more code? What I gave is the "fix" to what you posted.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER
pingeyeg

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

hielo

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.
ASKER
pingeyeg

Still getting the same thing.  Resource id #3
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
pingeyeg

What's weird is the fact that the page IS updating yet I am still getting Resource id #3 instead of the $result.
ASKER
pingeyeg

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.