Jump to content

Newbie question


nubble

Recommended Posts

Can't figure out the darn syntax on this... maybe I'm trying to do something that's not possible?  I have a field for snakeID, which is how I identify one critter from another.  I want the page to display just records for that snake on the page, in this case the snakeID is BM05J10.  I can get it to work when I format the query like this:

$sql = "select `snakeID`, `date`, `weight` from `weights` where `snakeID` like 'BM05J10' ORDER BY date DESC";

So what I'd like to do is do is be able to define the snakeID I'm working on in one variable at the top of the page, so I don't have to re-write the code for every critter.

<?php $critter="BM05J10"; ?>
<html>
<head>

When I try to put these two concepts together, I get a syntax error.  I know the problem is in this line of code, but can't figure out what's wrong with it.

$sql = "select `snakeID`, `date`, `weight` from `weights` where `snakeID` like '".$critter."' ORDER BY date DESC";

When I use this, I get no records at all.

I'm sure its something dumb - newbie stuff :(

-Amy
Link to comment
https://forums.phpfreaks.com/topic/23548-newbie-question/
Share on other sites

Archived

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

×
×
  • Create New...

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.