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

Link to comment
Share on other sites

<?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
Share on other sites

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
Share on other sites

$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
Share on other sites

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  ;D

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.