mysql UPDATE not working! Why?

Reply

Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

mysql UPDATE not working! Why?

 
0
  #1
Sep 27th, 2006
Very simple code, I even echo the variables to make sure they are comming through:
[PHP]<?
include 'config.php';

$recordid = $_POST['recordid'];
$im=$_POST['im'];
$bm=$_POST['bm'];
$peachtree=$_POST['peachtree'];
$canapprove=$_POST['canapprove'];
$cancomment=$_POST['cancomment'];
$canclose=$_POST['canclose'];
$administrator=$_POST['administrator'];

echo $im;
echo $bm;
echo $peachtree;
echo $canapprove;
echo $cancommnet;
echo $canclose;
echo $administrator;
echo "<p>";


$result = mysql_query("UPDATE employees SET im='$im', bm='$bm', peachtree='$peachtree', canapprove='$canapprove', cancomment='$cancomment', canclose='$canclose', administrator='$administrator' WHERE RECORDID='$recordid'")
or die('sorry, no query');


echo "Success";

?>[/PHP]

It executes the code, and I get a success, with no query errors. But the database is not being updated. Any idea to what I'm doing wrong? Oh, and the variables are echoing out the correct values.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: mysql UPDATE not working! Why?

 
0
  #2
Sep 27th, 2006
Do you have access to phpmyadmin or the command line for mysql? If so, echo out your query and paste it directly into mysql. It should tell you the reason why the update isn't working. mysql_error() should tell you this also even if die() isn't working.
Last edited by stymiee; Sep 27th, 2006 at 11:32 am.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: mysql UPDATE not working! Why?

 
0
  #3
Sep 27th, 2006
You can set your query in a variable and then echo that out. I don't think that will help, but it's another option.
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: mysql UPDATE not working! Why?

 
0
  #4
Sep 27th, 2006
Originally Posted by stymiee View Post
Do you have access to phpmyadmin or the command line for mysql? If so, echo out your query and paste it directly into mysql. It should tell you the reason why the update isn't working. mysql_error() should tell you this also even if die() isn't working.
Thanks. Yes, I do have access to the mysql database, and I have tried running the query directly in the command line, and didn't get any errors. That's why this is so boggling!
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: mysql UPDATE not working! Why?

 
0
  #5
Sep 27th, 2006
That is mind boggling. I guess at this point I can only wish you luck.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: mysql UPDATE not working! Why?

 
0
  #6
Sep 28th, 2006
Thanks for all your ideas. I figured it out. First, the reason my tests were working when I would paste the code into the mysql command line was because I knew I couldn't use the variables in there, so I replaced them all with numbers, so of course it would work.

And I was echoing out all the variables except for one. I was echoing all the variables that I was updating on the row, but not the one that defines WHICH row to update. The one after the WHERE! Anyway, I tried echoing that out, and realized that it wasn't getting passed from the form. Then I realized, it's not actually part of the form, I needed to pass it on using a hidden input field, and forgot to do that.

So, long story short, I wasn't echoing all my variables. Problem solved!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4418 | Replies: 5
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC