rkomar Posted July 13, 2007 Share Posted July 13, 2007 Hello, This url worked with globals on and I am want to get this all to work in globals off. Please give me an idea on how to pass this var in the url <a href="/directory/file.php?JobID=<?php echo $JobID ?>"> I can not get it to pass a the var with globals off.... Any help appreciated. Reply Quote Link to comment Share on other sites More sharing options...
micah1701 Posted July 13, 2007 Share Posted July 13, 2007 $_GET['JobID'] vars passed in the URL are put in an array called $_GET if they're submited to the page through a form its $_POST so <a href="/directory/file.php?JobID=<?=$_GET['JobID'] ?>"> Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 For some reason this is not passing the jobid data... ??? ??? Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 This is the whole statement.. ??? Don't know if that makes a diff.. <? while($myrow = mysql_fetch_array($result)) { $rows++; if(is_integer($color/2)) { ?> <tr BGCOLOR=#cococo> <? } else { ?> <tr BGCOLOR=#ffffff> <? } $color++; $JobID = $myrow["JobID"]; $Date1 = $myrow["Date1"]; $PositionTitle = $myrow["PositionTitle"]; $JobCity = $myrow["JobCity"]; $JobState = $myrow["JobState"]; $Date2 = $myrow["Date2"]; ?> <td width="20%" ><p align="left"><font color="000099"><? echo $Date1; ?></font></p></td> <td width="30%"> <p align="left"><a href="/directory/myfile.php?JobID=<?=$_GET['JobID'] ?>"> <font color="000099"> <?php echo $PositionTitle ?></a> </font> </p></td> <td width="25%" ><p align="left"><font color="000099"><? echo $JobCity; ?></font></p></td> <td width="5%"><p align="left"><font color="000099"><? echo $JobState; ?></font></p></td> <td width="20%"><p align="right"><font color="000099"><? echo $Date2 ?></font></p></td> </tr> <? } mysql_free_result($result); mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 this works now: <p align="left"><a href="/directory/myfile.php?JobID=<? echo $JobID ?>"> This does now work: <a href="/directory/file.php?JobID=<?=$_GET['JobID'] ?>"> If fails to pass the var JobID Quote Link to comment Share on other sites More sharing options...
cybercrypt13 Posted July 13, 2007 Share Posted July 13, 2007 try adding a semi colon after your $jobid; ?> Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 You would have thought that would have worked.... I did't.. Does is make a different if the globals are on or off with this code: <a href="/directory/myfile.php?JobID=<?=$_GET['JobID']; ?>"> This is not working and quit confusing as to why it is not... Thanks to all who have looked... ??? Quote Link to comment Share on other sites More sharing options...
hcdarkmage Posted July 13, 2007 Share Posted July 13, 2007 You could try <a href="/directory/file.php?JobID=<?=$_GET[var.JobID] ?>"> or even <a href="/directory/file.php?JobID=[var.JobID]"> Quote Link to comment Share on other sites More sharing options...
cybercrypt13 Posted July 13, 2007 Share Posted July 13, 2007 actually I think you are confused. You seem to be trying to use the query string before you get it. That Get part needs to be done on the myfile.php file you are calling, not on the page that is setting up the link. YOu can't use it until you push it to the next page. glenn Quote Link to comment Share on other sites More sharing options...
cybercrypt13 Posted July 13, 2007 Share Posted July 13, 2007 You also did not read my previous post because you still don't have a semi colon after that $_GET sequence which is required. glenn Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 I am sorry.. Not I really do have the ; there... really... <a href="/amember/moreinfo.php?JobID=<?=$_GET['JobID']; ?>"> Quote Link to comment Share on other sites More sharing options...
hcdarkmage Posted July 13, 2007 Share Posted July 13, 2007 Didi you try <a href="/directory/file.php?JobID=[var.JobID]"> ? That seems to work in some of the scripts I've seen. Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 Didi you try <a href="/directory/file.php?JobID=[var.JobID]"> ? That seems to work in some of the scripts I've seen. Yes I just tried that one and it will not work either... So as cybercrypt13 said "I am confused" Right now this is the only thing that works;; <a href="/directory/myfile.php?JobID=<?php echo $JobID ?>"> Quote Link to comment Share on other sites More sharing options...
cybercrypt13 Posted July 13, 2007 Share Posted July 13, 2007 but that would be the only thing that works. I'm not following where your problem is. lets start over... 1) where is $JobID coming from? It can only be a $_GET if a previous page (not the one you are on but the one before it) pushed it to you. You are trying to push it to yet another page so I'm assuming you got the var from the previous page and are trying to push it off to the next. If this is not the case then it will not work. 2) If in fact the $JobID came from the previous page and you can echo it then what you're doing will work. However, the fact that you say echo $JobID works, I suspect you are not in fact pushing that var from the previous page and you think you are going to use something that hasn't moved yet. So yes, one of us is very confused... :-) Quote Link to comment Share on other sites More sharing options...
hcdarkmage Posted July 13, 2007 Share Posted July 13, 2007 It would also help if your code was placed in code tags to make sifting through it easier. Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 Actually the previous page pushed the type of position and on the myfile.php page I have this: <? $conn = mysql_connect("myhost", "myusernane", "mypassword"); mysql_select_db("mydatabase",$conn); $sql = "SELECT DATE_FORMAT(DatePosted,'%m/%d/%y') AS Date1, DATE_FORMAT(ClosingDate,'%m/%d/%y') AS Date2, JobID, DatePosted, PositionTitle, JobCity, JobState, ClosingDate FROM jobs WHERE PositionType = '" . mysql_real_escape_string($_GET['PositionType']) . "' Order by JobState, JobCity "; $result = mysql_query($sql); ?> Then comes this - that lists the jobs and there in lays the url for the next link (myfile.php which gives more information on the choosen job.... <? while($myrow = mysql_fetch_array($result)) { $rows++; if(is_integer($color/2)) { ?> <tr BGCOLOR=#cococo> <? } else { ?> <tr BGCOLOR=#ffffff> <? } $color++; $JobID = $myrow["JobID"]; $Date1 = $myrow["Date1"]; $PositionTitle = $myrow["PositionTitle"]; $JobCity = $myrow["JobCity"]; $JobState = $myrow["JobState"]; $Date2 = $myrow["Date2"]; ?> <td width="20%" ><p align="left"><font color="000099"><? echo $Date1; ?></font></p></td> <td width="30%"> <p align="left"><a href="/directory/myfile.php?JobID=<?php echo $JobID ?>"> <font color="000099"> <?php echo $PositionTitle ?></a> </font> </p></td> <td width="25%" ><p align="left"><font color="000099"><? echo $JobCity; ?></font></p></td> <td width="5%"><p align="left"><font color="000099"><? echo $JobState; ?></font></p></td> <td width="20%"><p align="right"><font color="000099"><? echo $Date2 ?></font></p></td> </tr> <? } mysql_free_result($result); mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
per1os Posted July 13, 2007 Share Posted July 13, 2007 <a href="/directory/file.php?JobID=<?=$_GET['JobID'] ?>"> You do realize that the <?= was depreciated right? The correct way is the only way that works, fancy that. <a href="/directory/file.php?JobID=<?php echo $_GET['JobID'] ?>"> Is the correct way and that is why it works. Stop trying to get the depreciated method to work and just be happy that a method works. Sheesh! Quote Link to comment Share on other sites More sharing options...
hcdarkmage Posted July 13, 2007 Share Posted July 13, 2007 You seem to be missing a ; in your code. <td width="20%"><p align="right"><font color="000099"><? echo $Date2; ?></font></p></td> And you closed an <a href=" "> with a [/url]. It should be "</a>". EDIT: Apparently you can't use < slash a> in post. Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 Thanks for you input frost110. Oh.. abtw.. it does work.. imagine that.. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 13, 2007 Share Posted July 13, 2007 You seem to be missing a ; in your code. <td width="20%"><p align="right"><font color="000099"><? echo $Date2; ?></font></p></td> And you closed an <a href=" "> with a [/url]. It should be "</a>". EDIT: Apparently you can't use < slash a> in post. Thats what the [ code ] tags are for. Thanks for you input frost110. Oh.. abtw.. it does work.. imagine that.. If it does work I wouldn't code for it, in a year or two when you are updated to PHP 5 those tags will no longer work and your script is toast. Quote Link to comment Share on other sites More sharing options...
hcdarkmage Posted July 13, 2007 Share Posted July 13, 2007 Sometimes it doesn't help to get out of bed in the mornings. I was a fool to think that I could get away with not using the [ code ] tags. Then again, the original poster didn't use them either. Quote Link to comment Share on other sites More sharing options...
rkomar Posted July 13, 2007 Author Share Posted July 13, 2007 I know you won't mind if I take my problem to another board. I am just looking for some help with an old php code and trying to update it before moving it onto a newer server and hence a newer version of php/mysql. I really did not mean to turn this into a debate. Thanks to all that sincerely helped. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.