Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have this code (I know that the email is defined)

 <?php
$con=mysqli_connect($host,$user,$pass,$database);
 if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT `note` FROM `glogin_users` WHERE email = '.$email.'");

while($row = mysqli_fetch_array($result))
echo $row
?>

In my MySQL database I have the following setup (Table name is glogin_users) id email note

I've tried extracting the note text from the database and then echo'ing it but it doesn't seem to echo anything.

share|improve this question
2  
Have you checked your error log? What errors do you get? What steps have you taken to troubleshoot this? Have you run the query from the command line? – John Conde Mar 29 at 12:52
Can you post the error you are getting? – Barranka Mar 29 at 12:54

closed as too localized by John Conde, Daniel Vérité, Michael Irigoyen, Hanlet Escaño, Jonathan Kuhn Mar 29 at 18:26

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

3 Answers

What you are doing right now is you are adding . on the string and not concatenating. It should be,

$result = mysqli_query($con,"SELECT `note` FROM `glogin_users` WHERE email = '".$email."'");

or simply

$result = mysqli_query($con,"SELECT `note` FROM `glogin_users` WHERE email = '$email'");
share|improve this answer
2  
In addition to that - echo $row won't yield the expected, as $row is an array. It should be echo $row['note'] – Havelock Mar 29 at 12:55
1  
Thank you for your help, this resolved the situation :). – user2224376 Mar 29 at 12:58
you're welcome :D please also read the comment of @Havelock. – JW 웃 Mar 29 at 12:59
just 1 more problem. I'm echoing my notes, however there seems to be lots of whitespace before the actual text. I'm not really sure on how to deal with this. – user2224376 Mar 29 at 13:06
2  
how about trimming it? trim($row['note']) – JW 웃 Mar 29 at 13:07

You have to do this to echo it:

echo $row['note'];

(The data is coming as an array)

share|improve this answer
1  
also, you got wrong use of dot in the query.. – Raheel Hasan Mar 29 at 12:57

$result = mysqli_query($con,"SELECT note FROM glogin_users WHERE email = '".$email."'");
while($row = mysqli_fetch_array($result))
echo $row['note'];

share|improve this answer

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