1

It says the error is in the while loop.

    <?php

    $my_connection = mysql_connect('localhost','root','');

    if(!$my_connection){
            die('Could not connect: ' . mysql_error());
    }

    echo 'Connected successfully' . '<br><br>';

    $my_database = mysql_select_db('jihoon');

    if(!$my_database){
        die('Could not find database: ' . mysql_error());
    }

    $query='SELECT * FROM comments";

    $result=mysql_query($query);

    $my_rows;

    while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
        $my_rows = $my_rows . "id : {$row['id']}";
    }

    mysql_close($my_connection);

    ?>
2
  • 1
    did you see this error: $query='SELECT * FROM comments"; you need to use two of the same brackets quotes. $query="SELECT * FROM comments"; Commented Jul 24, 2011 at 16:49
  • 1
    hopefully you are using a password for you db and just filled in custom values for post...:) Commented Jul 24, 2011 at 16:53

4 Answers 4

3

If you take a look at the syntax-coloring of your question, here on StackOverflow, you'll notice that it starts getting broken at this line :

$query='SELECT * FROM comments";

You must use the same kind of quote at the beginning and end of your string.


So, you should use either :

$query='SELECT * FROM comments';

or :

$query="SELECT * FROM comments";

But not a bit of both ;-)

Sign up to request clarification or add additional context in comments.

Comments

1
$query='SELECT * FROM comments";

should be

$query="SELECT * FROM comments";

Comments

1

$query = 'SELECT * FROM comments";

Change to:

$query = "SELECT * FROM comments";

Different quotation marks.

Comments

1

You are using a double quote in end $query='SELECT * FROM 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.