hello gang,

I can't find any info on this anywhere, so I thought I'd post it here.

I have numerious queries which have the following simple structure:

$somevar = mysql_query("SELECT * FROM table");

note the semicolon. It's there, and always has been there. The querys used to work, but now, as of yesterday or maybe the day before, they are failing, returing FALSE.

in phpmyadmin, the querys work, and I can see my data there, but they don't work with the semicolon now.

If I remove the semicolon, I get nothing. The whole script just doesn't execute.

I'm a newbie, and I realize the manual says that the the query string SHOULD not end in a semicolon. But it doesn't say it MUST NOT end with a semicolon, and these queries were working fine just recently.

My provider says the semicolon is problem, but I'm confused. (I'm easily confused, mind you. : )) Has something changed with PHP recently?

I swear that these queries were working until just the other day, with their semicolons.

Please help, cause I'm at a total loss.

Thanks in advance

Rich

    misunderstanding:

    NO semicolon: at the end of sql statements (unlike in an sql shell)

    ALWAYS a semicolon: at the end of php commands.

    false:
    mysql_query("SELECT FROM table;");
    right:
    mysql_query("SELECT
    FROM table");

    false:
    echo "xy"
    right:
    echo "xy";

    got it? 🙂

      Matto,

      Thanks, that's what I thought.

      Any ideas why my queries suddenly stopped working?

      My provider says the semicolon is a no-no. I am totally confused -- they used to work, but now they don't.

        4 months later

        if the query return false, there can be some error. Try this:

        $somevar = mysql_query("SELECT * FROM table");
        echo "Error: >> ".mysql_error()." <<";

        It should tell you what goes wrong.

        The semicolons has no affect here,

        SELECT * FROM table;

        should have the same effect like

        SELECT * FROM table

        in php.
        Tom

          Write a Reply...