Solved

Syntax error...probably something simple

Posted on 2004-08-19
6
214 Views
Last Modified: 2013-12-12
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
Comment
Question by:Steve_Newbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:akshah123
ID: 11846530
your this line of code

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

is not getting anything.  That's the problem
0
 
LVL 17

Expert Comment

by:akshah123
ID: 11846533
perhaps botth $_GET[to] and $_GET[ID] are empty.
0
 

Author Comment

by:Steve_Newbie
ID: 11846587
?
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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 17

Accepted Solution

by:
akshah123 earned 100 total points
ID: 11846619
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
 

Author Comment

by:Steve_Newbie
ID: 11846713
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
 

Author Comment

by:Steve_Newbie
ID: 11846723
IF I am missing something (which is way probable) please don't hesitate to post a final comment.  Thanks again.
Steve
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question