0
$selectedItem = mysql_escape_string($_POST['select']);
$id= mysql_escape_string($_POST['id']);

if ($selectedItem == "ID")
    {
        echo 2;
        $nome = mysql_query("SELECT nome FROM `eventos` WHERE ID = '$id'");
        echo $nome;
    }

Ok, i want to show the name of one event of id that i insert in textbox. It shows me 2, so if statement is working but when i say to show nome show me: 2Resource id #5

I have one row in table eventos with id = 1 and i put always in textbox number 1.

Why it doesnt show me the text that i have in collumn nome?

1
  • mysql_query function returns a resource on success, or FALSE on error according to the documentation. in your case, it returns success. try user3091574's suggestion. Commented May 8, 2014 at 9:18

1 Answer 1

1

try this

$n = mysql_fetch_array($nome);
echo $n['nome']; 

It's recommended to use mysqli_query instead of mysql_query
like this

 //
 $nome = mysqli_query("SELECT nome FROM `eventos` WHERE ID = '$id'");
 $n = mysql_fetch_array($nome);
    echo $n['nome'];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.