| | |
mysql UPDATE not working! Why?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
[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.
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!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
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.
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.
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!
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!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
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!
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!
![]() |
Similar Threads
- mysql DELETE not working (PHP)
- UPDATE query not working properly... (PHP)
- mysql update help??? (PHP)
- new to mySQL (MySQL)
- 6 working keys on laptop keyboard, rebooting... (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: create password storage/retrieval program?
- Next Thread: Update array variable
Views: 4418 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






