Jump to content

echoing a varible shows the name of the variable


kanuski

Recommended Posts

Greetings,

I am using a drop-down menu to pass a variable, $clid with a value of '1', to the next page. When I echo it on the next page it prints $clid instead of '1'.

<? echo "CLID: $clid"; ?>

This prints

CLID: $clid

 

  The drop-down menu is in a separate txt file and works everywhere else on my site. All the other variables are working great. What could cause this kind of problem?

 

<?

$query3 = "select * from classrooms

where tid LIKE '$uid'";

$result3 = mysql_query ($query3);

$num_rows3 = mysql_num_rows($result3);

if ($data3 = mysql_fetch_array($result3))

{

echo "<SELECT name='clid' style='background-color : #a8b6e2; border-bottom-color : #677c8f; border-left-color : #677c8f; border-right-color : #677c8f; border-top-color : #677c8f;'>";

$count="0";

do

{

$clid1=$data3[0];

$classcode1=$data3[2];

 

echo "<option value='$clid1'>$classcode1</option>";

$count=$count+1;

} while($data3 = mysql_fetch_array($result3));

echo "</SELECT>";

$classrooms="yup";

}

if($num_rows3<1) { echo "<em>No classrooms created.</em>"; $classrooms="nope"; }

 

?>

 

 

Thanks, that isn't working either.

The code I am using is actually part of a much larger section. The only reason I want to print it is to see why it is not working. I am storing this data in a database and this variable is always showing up as 0. The others work great.

echo "CLID: $clid <br>month: $month<br>mo_num: $mo_num<br>day_num: $day_num<br>";

Somehow the value of $clid is becoming $clid.

 

 

cool = ))

 

yah, sometimes just echoing things out doesn't help... using var_dump and print_r for arrays is essential to get to the deeper issue. They're excellent troubleshooting tools. Don't feel like an idiot. You just learned something you will use a zillion times now, and start finding your problems without asking and having to wait for help. Good luck man

 

PhREEEk

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.