• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

Syntax error...probably something simple

Hello.
Can't get rid of a sytax error.  The code works (to send a message) ,but get the error re syntax ::

Code :
$nick = db_arr("SELECT NickName FROM Profiles WHERE ID=".($_GET[to]? $_GET[to] : $_GET[ID]));


Error:
Error in /compose.php: 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 '' at line 1
Query: 'SELECT NickName FROM Profiles WHERE ID='


Help?
Thanks.
STeve
0
Steve_Newbie
Asked:
Steve_Newbie
  • 3
  • 3
1 Solution
 
akshah123Commented:
your this line of code

($_GET[to]? $_GET[to] : $_GET[ID])

is not getting anything.  That's the problem
0
 
akshah123Commented:
perhaps botth $_GET[to] and $_GET[ID] are empty.
0
 
Steve_NewbieAuthor Commented:
?
Not a programmer, so pardon if this does not make sense.....but this code seems to define NickName, so that $nick is set and echos correctly when called one line later via:
echo "<b>TO:<font color=red>$nick[0]</font></b>";

Without that line $nick and NickName do not echo.....with it, $nick does.  (That is what I am trying to do with this.)  
?
Steve
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
akshah123Commented:
I understand what you are tyring to do but the problem is that variable $_GET[to] and $_GET[ID] do not hold any values.

Try this

$nick = db_arr("SELECT NickName FROM Profiles WHERE ID=\"".($_GET[to]? $_GET[to] : $_GET[ID]) . "\"");

If above does not return anything then  $_GET[to] and $_GET[ID] are empty.
0
 
Steve_NewbieAuthor Commented:
Actually, it works fine.  That was it.  Don't ask....been working on the actual code for two weeks to get it to do the message echo and send....this was just the final touch (getting rid of the syntax error).  IT works, well, and that is fine......
Thanks very much.
!!
Steve
0
 
Steve_NewbieAuthor Commented:
IF I am missing something (which is way probable) please don't hesitate to post a final comment.  Thanks again.
Steve
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now