Jump to content

Recommended Posts

I am running a simple php mysql_connect but I keep on getting the following error:

 

Connected to MySQL

Error: 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 'FROMÂ jos_menu' at line 1

 

I don't understand what the issue is here, teh syntax seems to be correct but there is something wrong with the mysql_query.  Can anyone spot the issue here and please help.  This query was running fine before.  I have tried this on my godaddy account (linux) and also on my local machine which is using xampp on windows xp.  I keep on gettnig the same error.  Below is my code please help!

 

 

<?php
$username = "myname";
$password = "pwd";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) 
  or die ('Error: '.mysql_error ());
echo "Connected to MySQL<br>";

mysql_select_db("dbname", $dbhandle);

$result = mysql_query("SELECT * FROM jos_menu") or die ('Error: '.mysql_error ());

while ($row = mysql_fetch_array( $result )) 
{echo $row['parent_id']; 
}

mysql_close($dbhandle);
?>

suer thing maq, didn't know about that code thing before.

 

Just wanted to thank kenrbnsn , retyping the code has solved the issue, I don't know how you picked that up, but it worked and the non-ascii was the cause.  I am new to php, is there a light weight utility that I can use to type code in so in the future this type of error can be avoided.  Thanks so much for your help

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.