Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with URL variables

Status
Not open for further replies.

MarlaJ

Programmer
Jul 21, 2003
20
US
I'm passing variables in my url and reading them on a page (i.e. and my code doesn't appear recognize the variables "ctypeid" and "list". When I echo $ctypeid and $list on my page they are both null. My code for tt.php works on my development server and the variables are recognized fine but not on the production . Other php pages which pass a variable (i.e. work fine, regardless of the server.

I'm attaching the relevant code here:

Code:
<?php include(&quot;db_connect.php&quot;);?><?php echo &quot;list = &quot;.$list.&quot;<br>ctypeid=&quot;.$ctypeid;?><?
 if ($list==0)
 	{
$tips_query = &quot;SELECT * from news where newsid=$newsid&quot;;
						$tips_result = mysql_query($tips_query, $conn);
						$tips_num_rows = mysql_num_rows($tips_result);
							if ($tips_num_rows == 0)
								{
								echo &quot;we have no records&quot;;
								/*echo &quot;there were $login_num_rows returned<p>&quot;;*/
								}
							else
								{	echo &quot;<table><tr><td width=\&quot;50%\&quot;><b>&quot;;
									 if ($ctypeid==2){echo &quot;Tips & Tricks&quot;;} 
									 else if ($ctypeid==3) {echo &quot;News&quot;;} 
									 else if ($ctypeid==1) {echo &quot;Whitepapers&quot;;}
									 else if ($ctypeid==4) {echo &quot;Macro Library&quot;;}
									 echo &quot;</b></td></tr>&quot;;	
									for ($i=0; $i<$tips_num_rows; $i++)
									{
									$row=mysql_fetch_array($tips_result);
									$year = substr($row[&quot;dateadded&quot;], 0,4);
									$day = substr($row[&quot;dateadded&quot;],8,2);
									$month = substr($row[&quot;dateadded&quot;],5,2);
									$newsdate=$month.'-'.$day.'-'.$year;
									echo &quot;<tr><td>&quot;;
									echo $row[&quot;headline&quot;];
									echo &quot;<br><i>&quot;;
									echo $row[&quot;tinydescription&quot;];
									echo &quot;</i><br>&quot;;
									echo $row[&quot;description&quot;];
									echo &quot;</td></tr>&quot;;
									
									}
									echo &quot;</table>&quot;;
								}
			}
else if ($list==1)
	{
$tips_query = &quot;SELECT * from news where ctypeid=$ctypeid&quot;;
						$tips_result = mysql_query($tips_query, $conn);
						$tips_num_rows = mysql_num_rows($tips_result);
							if ($tips_num_rows == 0)
								{
								echo &quot;we have no records&quot;;
								/*echo &quot;there were $login_num_rows returned<p>&quot;;*/
								}
							else
								{	echo &quot;<table><tr><td width=\&quot;50%\&quot;><b>Date Added</b></td><td width=\&quot;50%\&quot;><b>&quot;;
									 if ($ctypeid==2){echo &quot;Tips & Tricks&quot;;} 
									 else if ($ctypeid==3) {echo &quot;News&quot;;} 
									 else if ($ctypeid==1) {echo &quot;Whitepapers&quot;;}
									 else if ($ctypeid==4) {echo &quot;Macro Library&quot;;}
									 echo &quot;</b></td></tr>&quot;;	
									for ($i=0; $i<$tips_num_rows; $i++)
									{
									$row=mysql_fetch_array($tips_result);
									echo &quot;<tr><td>&quot;;
									echo $row[&quot;dateadded&quot;];
									echo &quot;</td><td><a href=\&quot;tt.php?ctypeid=&quot;;
									echo $ctypeid;
									echo &quot;&list=0&&quot;;
									echo &quot;newsid=&quot;;
									echo $row[&quot;newsid&quot;];
									echo &quot;\&quot;>&quot;;
									echo $row[&quot;headline&quot;];
									echo &quot;</a><br>&quot;;
									//echo &quot;<i>&quot;;
									//echo $row[&quot;tinydescription&quot;];
									//echo &quot;</i><br>&quot;;
									//echo $row[&quot;description&quot;];
									echo &quot;</td></tr>&quot;;
									
									}
									echo &quot;</table>&quot;;
								}
			}								
								?>

The production server is brand new and we've never used it before. I'm not sure if it matters but register_globals=On in the php.ini. Any help would be greatly appreciated as the site is supposed to go live today :(
 
Appreciate the response but the FAQ doesn't help me - I had already read this stuff as well as php.net's discussion on it before I posted here and all I got was more confused. I've tried register_globals = On and register_globals = Off and saw no difference unless I'm looking at the wrong ini file.

If it works properly on one page, why doesn't it work on other pages? I just don't understand.

I did find out that the development server is working with a pre-4.2 version of php whereas the production one is 4.3.2.
 
Did you restart the web browser after editing php.ini?

If you run a script consisting of:

<?php phpinfo(); ?>

Does PHP say it's reading the php.ini file you edited? Sometimes you can get multiple php.ini files on the server and be editing one while PHP is reading the other.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
just a wild guess here but could it be the ampersand that you are passing instead of &amp the bit that says

&quot; A more portable way around this is to use &amp; instead of & as the separator. You don't need to change PHP's arg_separator for this. Leave it as &, but simply encode your URLs using htmlentities(urlencode($data)). &quot;

Not sure if its relevant though. let us know how u get on. or the soloution

To err is human, to completely mess up takes a computer. [morning]
 
&quot;use & instead of &&quot;

I don't see the difference, did TGML mess it up?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top