porta325 Posted July 14, 2007 Share Posted July 14, 2007 this is a piece of my showlinks.php mysql_connect("localhost", "xxx", "xxx") or die(mysql_error()); mysql_select_db("xxx") or die(mysql_error()); $judet = $_GET['judet']; $result = mysql_query ("SELECT oras, id_oras FROM orase WHERE id_oras = '$judet' ORDER BY oras"); what i don't get is why it doesn't read the $judet variable witch i have in index.php, for a moment it worked but now it doesn't anymore and i can't identify the problem. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/ Share on other sites More sharing options...
uramagget Posted July 14, 2007 Share Posted July 14, 2007 Try not to leave a space for the $_GET data, and see if it works. Not sure if it makes a difference though. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298121 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 Nope, it has nothing to do. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298122 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 is it so stupid that nobody knows ? Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298129 Share on other sites More sharing options...
hackerkts Posted July 14, 2007 Share Posted July 14, 2007 Dude.. Mind what you're saying, you are asking for help so mind your language. Try to debug out the problem, echo out $_GET['judet']. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298132 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 I do echo out.Without the where clause it works, it just seems it can't read the $judet=$_POST['judet']. First time it worked it was because i removed {} from ..........FROM orase WHERE id_oras = '{$judet}' ORDER.......... After i made some changes to the a href line it stopped working. I got everything back like it was and again it's not working. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298139 Share on other sites More sharing options...
chigley Posted July 14, 2007 Share Posted July 14, 2007 <?php mysql_connect("localhost", "xxx", "xxx") or die(mysql_error()); mysql_select_db("xxx") or die(mysql_error()); $judet = $_GET["judet"]; $query = "SELECT oras, id_oras FROm orase WHERE id_oras = '{$judet}' ORDER BY oras ASC"; echo "Query: {$query}<br />\n"; $result = mysql_query($query) or die(mysql_error()); list($oras, $id_oras) = mysql_fetch_row($result); echo "Oras: {$oras}<br />\nID: {$id_oras}"; ?> What does that output? Are you aware that your topic is about $_POST yet your code uses $_GET? Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298142 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 says Query was empty this is what i have <?php mysql_connect("xxx", "xxx", "xxx") or die(mysql_error()); mysql_select_db("xxx") or die(mysql_error()); $judet = $_GET['judet']; $result = mysql_query ("SELECT oras, id_oras FROM orase WHERE id_oras = '$judet' ORDER BY oras"); ?> <?php while ($row=mysql_fetch_assoc($result)) { $oras=$row['oras']; echo "<a href=\"showtown.php?town=$oras\" class=\"links.css\">$oras</a>"; ?> <span class="style4"> ::</span> <?php Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298147 Share on other sites More sharing options...
hackerkts Posted July 14, 2007 Share Posted July 14, 2007 echo "<a href=\"showtown.php?town=".$oras."\" class=\"links.css\">".$oras."</a>"; Try that.. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298151 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 $oras it's ok. the only problem is that i can't get $judet = $_GET['judet']; so in the mysql querry i can't compare $judet with id_oras. The only problem here is the $_POST witch for don't know what reason it doesn't read the $judet from my index.php Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298157 Share on other sites More sharing options...
chigley Posted July 14, 2007 Share Posted July 14, 2007 Try using: $judet = $_POST["judet"]; I think you're muddling $_GET and $_POST up! Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298160 Share on other sites More sharing options...
hackerkts Posted July 14, 2007 Share Posted July 14, 2007 So you mean $_POST or $_GET? They are different, $_POST are passes by form, example <input type="text" name="judget"> To get the value from the form use $_POST['judget'], as for $_GET, to get the value it's by the link. Example, http://domain.tld/index.php?judget=VALUE Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298161 Share on other sites More sharing options...
AndyB Posted July 14, 2007 Share Posted July 14, 2007 says Query was empty No. Chigley's code suggestion would display the actual query string. What's the query string as displayed (not as coded). $_POST are passes by form - unless the form action is GET Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298163 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 Yes, my mistake, i was talking about $_GET and i tried like this: $judet = $_GET["judet"]; (double and simple quotes) $result = mysql_query ("SELECT oras, id_oras FROM orase WHERE id_oras = '{$judet}' ORDER BY oras") variable in mysql_query like this '{$judet}', i tried '$judet' , $judet i tried with all kind of spaces and quotes, it simply wont work, i just don't know why it wont read the $judet variable. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298175 Share on other sites More sharing options...
chigley Posted July 14, 2007 Share Posted July 14, 2007 My code can't have said query was empty, because it was defined 2 lines above! :S Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298180 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 I'm not makin this up, i can post a printscreen if you want. Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298182 Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 solved it seems it works like this echo "<a href=\"showlinks.php?judet=$judet\" class=\"links.css\">$judet</a>" and i had echo "<a href=\"showlinks.php?city=$judet\" class=\"links.css\">$judet</a>" Link to comment https://forums.phpfreaks.com/topic/59950-solved-stupid-_post-problem/#findComment-298188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.