Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

MySql error on UPDATE command


  • Please log in to reply

#1
TheWern

TheWern

    Member

  • Member
  • PipPip
  • 82 posts
Hi Guys,
p1plyr is the name associated with 2 radio buttons on a form. If either is checked, the command updates the form as intended. BUT, if neither are checked it returns the message below. My thoughts were that if neither were selected, the command would update the table with "" or the default which is 0.

Any help, as always, will be greatly appreciated.

$query="UPDATE tbl_results SET sUKRESp1plyr=$arVals[p1plyr] WHERE sUKRESusername = '$sesusername' AND sUKRESseasonend = 2007 AND sUKRESmatch = $_SESSION[REQmatch]"; //iPuserid=$userid
$result = mysql_query($query) or die("Invalid query: " . mysql_error() . "<br><br>". $query);

Invalid query: 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 'WHERE sUKRESusername = 'yyyy' AND sUKRESseasonend = 2007 AND sU
UPDATE tbl_uk_soc_results SET sUKRESp1plyr= WHERE sUKRESusername = 'yyyy' AND sUKRESseasonend = 2007 AND sUKRESmatch = 1
  • 0

Advertisements


#2
scozzard

scozzard

    Member

  • Member
  • PipPip
  • 26 posts
what is the datatype of the value you are sending in the query? If your datatype is an integeter for example, a null or "" will not be parsing and therefore stuffing up your query
  • 0

#3
TheWern

TheWern

    Member

  • Topic Starter
  • Member
  • PipPip
  • 82 posts
Hi,

It was smallint which I changed to Char but made no difference. I then changed the session funcs for p1plyr from ="" to =0 and this has sorted it out, whether smallint or char.
I dont know for sure why this worked unless a radio button has to have an integer value? ? or because I made the default 0 ? ? ?

I would like to know, but either way it worked. Thanks for pointing me in the right direction.

Sandy
  • 0

#4
maros84

maros84

    New Member

  • Member
  • Pip
  • 1 posts
Hi,

Try with this changed code. If you are using arrays in the query, it's better to concat it.

$query="UPDATE tbl_results SET sUKRESp1plyr='".$arVals[p1plyr]."' WHERE sUKRESusername = '$sesusername' AND sUKRESseasonend = 2007 AND sUKRESmatch = '".$_SESSION[REQmatch]."'"; //iPuserid=$userid
$result = mysql_query($query) or die("Invalid query: " . mysql_error() . "<br><br>". $query);

If the problem will still be there, you can also check if the array is empty or not.
i.e.
if (empty($arVals[p1plyr])) $arVals[p1plyr] = '0';

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP