Jump to content

[SOLVED] stupid $_POST problem


porta325

Recommended Posts

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

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.

<?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?

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

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.