user1942505
user1942505

Reputation: 520

Command causes error in SQL syntax

Why do I receive an error message for this?

<?php
$output ="";
$query = "HELP;";
$output = mysql_query($query, $emailTrackerConnection) or die(mysql_error());

echo "<pre>$output</pre>";
?>

The output I receive:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Upvotes: 0

Views: 101

Answers (3)

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115530

HELP ; will return this error. Try using HELP 'statement or keyword or operator' ; to get help on a specific keyword.

If you want to find what keywords/operators/statements are available for use with HELP, use this:

HELP '%' ;

Upvotes: 1

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146450

HELP; (without parameters) is an internal command of the MySQL command line tool rather than a SQL command:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1862
Server version: 5.1.39-community MySQL Community Server (GPL)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

However, if you add a search string you do get a SQL command:

HELP 'search_string'

Upvotes: 3

John Woo
John Woo

Reputation: 263723

you show specify a keyword when using HELP, eg.

HELP 'contents'

Upvotes: 1

Related Questions