Link to home
Start Free TrialLog in
Avatar of mhoggatt1
mhoggatt1

asked on

$result syntax error

I am receiving an error message on line 14 of the following script.
I have included the message in a comment line above line 14.

<?php
      $include_path = "";
      require_once($include_path. 'uis.php');
      require_once($include_path. 'myconfig.php'); // Connect to the DB

     $i=0;
     $j=0;

// This statement works on my Windows XP machine
// but not on the Linux OS
// Here is the error message -
/* Sql error : You have an error in your SQL syntax near 'ORDER BY directory_name ASC' at line 1 */

$result = mysql_query("SELECT DISTINCT jz_directoryID, directory_name, directory_link FROM ".$myconfig->dt['jz_directory']." ORDER BY directory_name ASC") or die("Sql error : " . mysql_error());

$num_rows = mysql_num_rows($result);
echo "number of rows = $num_rows<br>";

while ($row = mysql_fetch_array($result)) {

$directory_name = mysql_result($result,$i,"directory_name");
$directory_link = mysql_result($result,$i,"directory_link");

echo "Directory name is $directory_name<br>";
echo "Directory link is $directory_link<br><br>";
     }
?>

Thanks for your help.
Michael
Avatar of MasonWolf
MasonWolf
Flag of United States of America image

perhaps $myconfig hasn't been initialized the way you think. Try:
echo "SELECT DISTINCT jz_directoryID, directory_name, directory_link FROM ".$myconfig->dt['jz_directory']." ORDER BY directory_name ASC";

See if you get what you're expecting.
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey. I guess we all know what the problem is then! Ha ha
Or at least our eyes were all pulled in the same direction. I'm curious to see how the author responds.
Avatar of mhoggatt1
mhoggatt1

ASKER

Well it happens to the best of us. I forgot to upload myconfig.php !
That's what happens when you're working on 2 different machines at once.

Thanks again,
Michael
All three of us gave the same answer - check your value for $myconfig. Why was my answer not included in the points split?
Hi MasonWolf,
   I tried the echo you suggested and it gave me a warning. Tell you what I'll do. I'll post your answer in a new question. Fix it and I'll give you 250 points !

Thanks for your help,
Michael
mhoggatt1, the reason it gave you a warning is because you had not configured the $myconfig correctly.

MasonWolf's comment is only valid.

All 3 of our answers should have given a warning.
Oops. Remove "only".
The warning should have given you an important clue about what was wrong - basically that $myconfig had not been set.
I posted your first suggestion at
https://www.experts-exchange.com/questions/22912394/PHP-echo-statement.html

So go there and I'll split points with you.

Thanks,
Michael
I'd really rather not. I appreciate the sentiment and all, but technically that is known as points-passing and it's a very big no-no on experts-exchange. I think it's even possible to get your account revoked by doing that. I'm going to just let bygones be bygones and chalk it up to experience. Please go to the customer support lounge and ask a moderator to close your question.
Hope to do business with you again sometime !