Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

MySql error on UPDATE command


  • Please log in to reply

#1
TheWern

TheWern

    Member

  • Member
  • PipPip
  • 81 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
  • 81 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