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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
porta325 Posted July 14, 2007 Author Share Posted July 14, 2007 Nope, it has nothing to do. Quote Link to comment 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 ? Quote Link to comment 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']. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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.. Quote Link to comment 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 Quote Link to comment 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! Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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>" 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.