View Full Version : UPDATE not working
Zaxza
April 17th, 2008, 09:28 PM
hi im working on a site as a hobby http://zaxza.awardspace.com/seocial/status.php?id=1
at the moment the ajax works fine but im having problems with the php
<?php
include("[connection page]");
if (isset($_GET['inputText']))
if ($_GET['inputText'] == ""){
echo ("What are you up to?");
}
else{
$id = "1"
echo ($_GET['inputText']);
mysql_query("UPDATE users SET status = '$_GET[inputText]' WHERE id = '$id' LIMIT 1");
}
?>
can anyone see a flaw im not seeing? any help would be greatly appreciated.
thanks
ZumoWrestler
April 17th, 2008, 11:47 PM
It's hard to tell. Few things you can do.
If it errors out without a response then start commenting out code until you fix the problem. Once it returns something desirable start echoing out at certain points, or var_dump(). Make sure you have an open connection to your database. Use the same query on the database directly. Echo out the final result of the entry. There are many other methods of figuring out your problem.
The key thing in programming is learning how to teach yourself!
simplistik
April 18th, 2008, 09:57 AM
Hmmm I'm not sure what the problem is looks like it's missing a bracket, but the code itself is a little sloppy, try something like:
<?php
include("[connection page]");
$inputText = $_GET['inputText'];
if ( isset($inputText) )
{
if ( $inputText == "" )
{
echo ("What are you up to?");
}
else
{
$id = "1"
echo ( $inputText );
mysql_query("UPDATE users SET status = '$inputText' WHERE id = '$id' LIMIT 1");
}
}
?>
This assumes that your include file is your database connection script.
@Zumo
I'd imagine that he did try to figure it out himself ... so telling him to keep looking after having been unsuccessful before posting, while not attempting to help his situation proves quite useless.
mBm
April 18th, 2008, 05:42 PM
should be
"UPDATE users SET status = '{$_GET['inputText']}' WHERE id = '$id' LIMIT 1"
or
"UPDATE users SET status = '".$_GET['inputText']."' WHERE id = '$id' LIMIT 1"
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.