rkomar Posted April 9, 2007 Share Posted April 9, 2007 Hi, I have some older php pages with the var in the url. I have to have global register off or it does not work. I hope to receive some help here so I can turn globals off. I have two pages main.php and main1.php On main.php I have the url var like this: a href="/mydirector/test101.php?JobID=<?php echo $JobID ?> And on the second page main1.php I have this: <? $conn = mysql_connect("admin.mysite.com", "username", "password"); mysql_select_db("database",$conn); $sql = "SELECT * FROM mysite WHERE JobID = '$JobID' "; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> Any help in making this work is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/ Share on other sites More sharing options...
kenrbnsn Posted April 9, 2007 Share Posted April 9, 2007 You now need to get the value explicitly from the $_GET superglobal array. <?php $sql = "SELECT * FROM mysite WHERE JobID = '" . mysql_real_escape_string($_GET['JobID']) . "'"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-224995 Share on other sites More sharing options...
rkomar Posted April 9, 2007 Author Share Posted April 9, 2007 That worked great. How about this one... main.php <a href="/mysite/search.php?PositionType=A new Position" main1.php <?php $conn = mysql_connect("admin.mysite.com", "username", "password"); mysql_select_db("database",$conn); $result = mysql_query("SELECT Count(*) AS total FROM mysite WHERE PositionType='$PositionType' "); $job_count = mysql_result($result, 0, 'total'); ?> Your reply worked great on the first one but it did not work here.. Thanks. Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225021 Share on other sites More sharing options...
kenrbnsn Posted April 9, 2007 Share Posted April 9, 2007 How did you change the second example and what error did you get? Ken Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225030 Share on other sites More sharing options...
rkomar Posted April 9, 2007 Author Share Posted April 9, 2007 In the Main1.php I did: <?php $sql = "SELECT * FROM mysite WHERE Positiontype = '" . mysql_real_escape_string($_GET['PositionType']) . "'"; ?> and nothing happened.. page just said done... Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225082 Share on other sites More sharing options...
rkomar Posted April 9, 2007 Author Share Posted April 9, 2007 I think I might have it working... maybe one of the ' or " got misplaced... Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225097 Share on other sites More sharing options...
rkomar Posted April 9, 2007 Author Share Posted April 9, 2007 It did not like this for a count: $result = mysql_query("SELECT Count(*) AS total FROM mysitedb PositionType = '" . mysql_real_escape_string($_GET['PositionType']) . "'"; I have the other ones working.. just the count does not like what I have done.. nothing is displayed... Thanks you for your time. Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225103 Share on other sites More sharing options...
trq Posted April 9, 2007 Share Posted April 9, 2007 You rmissing your WHERE clause. $result = mysql_query("SELECT Count(*) AS total FROM mysitedb WHERE PositionType = '" . mysql_real_escape_string($_GET['PositionType']) . "'"; Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225125 Share on other sites More sharing options...
rkomar Posted April 9, 2007 Author Share Posted April 9, 2007 $result = mysql_query("SELECT Count(*) AS total FROM mysite WHERE PositionType='" . mysql_real_escape_string($_GET['PositionType']) . "'"; I got this in there but it is not working... just a blank page ... I want to thank you for your help.. I got the other ones working and for some reason I just had a mental block and could not get what I was reading to work. Thanks again. Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225139 Share on other sites More sharing options...
rkomar Posted April 9, 2007 Author Share Posted April 9, 2007 OK.. I played with it till I got it... Must have been just some misplaced ' or "... Thanks again.. Link to comment https://forums.phpfreaks.com/topic/46260-php-get-and-vars/#findComment-225143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.