0

Any idea why this is not working:

$result = mysql_query("SELECT cust_name, description from `projects` where project_no = '".$project_no."'") or die(mysql_error());
            while ($row = mysql_fetch_array($result)) {
                echo json_encode(
                      array("message1" => '".$row['cust_name']."', 
                      "message2" => '".$row['description']."')
                 )
            }

This is the error: Parse error: syntax error, unexpected T_STRING, expecting ')' in /admin/customerfilter.php on line 14

Line 14 is the line starting with "array..."

Thanks :)

1
  • Format your code properly, and you'll see what's wrong... Always indent and use a syntax-highlighting IDE/editor and you won't have this problem... Commented Jan 4, 2011 at 14:16

2 Answers 2

4

Too many quotes:

$result = mysql_query("SELECT cust_name, description from `projects` where project_no = '".$project_no."'") or die(mysql_error());
            while ($row = mysql_fetch_array($result)) {
                echo json_encode(
                      array("message1" => $row['cust_name'], 
                      "message2" => $row['description'])
                 )
            }
Sign up to request clarification or add additional context in comments.

2 Comments

add the missing ; and it's perfect
I work just the way compiler does. Only fix the first error reported :P
3
echo json_encode(array(
    "message1" => $row['cust_name'],
    "message2" => $row['description'],
));

Don't make things more complicated than necessary.

1 Comment

Thanks! perfect, the last thing i was trying to do was complicate it :) just get it to work!

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.