Jump to content

Archived

This topic is now archived and is closed to further replies.

DaveLinger

I'm sure this is a very easily fixed problem, echoing contents of a variable

Recommended Posts

[code]switch ($pid)
{
  case 12:
    $sqlthing = 'WHERE newsecid IN (12,34,35,36,37,38,40,41,42,43,45,46,48)';
    break;
  case 13:
    $sqlthing = 'WHERE newsecid IN (13,35,36,37,39,40,41,42,43,44,45,46,47)';
    break;
  case 14:
    $sqlthing = 'WHERE newsecid IN (14,34,35,36,37)';
    break;
  case 20:
    $sqlthing = 'WHERE newsecid IN (20,38,39,40,41,44,45,47)';
    break;
  case 32:
    $sqlthing = 'WHERE newsecid IN (32,41,42,44,45,47)';
    break;
  case 16:
    $sqlthing = 'WHERE newsecid IN (16,48)';
    break;
  default:
    $sqlthing = 'WHERE newsecid= "$pid"';
    break;
}[/code]

if the $pid is none of the "case"s, I get an SQL error which says the query is WHERE newsecid=$pid , when $pid SHOULD be the number!

Share this post


Link to post
Share on other sites
try flipping your quotes around, that should do it

default:
    $sqlthing = "WHERE newsecid= '$pid'";
    break;

remember everything inside single quotes gets printed/expressed as is

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.