Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need help to query string from database please help.

<?php
$phone="[email protected]";


$link = mysql_connect('localhost', 'root', 'toor');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db('wizarddb')) {
    die('Could not select database: ' . mysql_error());
}
$result = mysql_query("SELECT * FROM Phone WHERE phone LIKE '%$phone%'"); 

if (!$result) {
    die('Could not query:' . mysql_error());
}
echo mysql_result($result(1); // outputs phone

mysql_close($link);
?>

I have issues with echo or is the query wrong?

share|improve this question
 
echo mysql_result($result(1); should be echo mysql_result($result(1)); (missing closing ')' ) –  Maximus2012 Sep 9 '13 at 21:16
 
is there any other error message that you are getting ? –  Maximus2012 Sep 9 '13 at 21:17
1  
what help do you need? Is there an error, something not working as you'd expect or it does nothing/white page? –  James Sep 9 '13 at 21:19
 
You have unbalanced parentheses, you should be getting a Parse Error. Or is that just a typo in the question, not the original code? –  Barmar Sep 9 '13 at 21:23
add comment

1 Answer

Your error is on the echo.

echo mysql_result($result(1); // outputs phone

That SHOULD be

echo mysql_result($result[1]); // outputs phone
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.