1

Any ideas why this wouldnt work!?

Just nothing displays..

$result1 = mysql_query("select * from `suppliers` where supp_short_code='WED'") or die(mysql_error());
                while($row1 = mysql_fetch_array($result1))
                    {       
                        echo "<p>" . $row1['supp_name'] . "</p>";
                    } 
2
  • 2
    Could you please post the output from mysql_error() so that we can see the error that is being raised. Commented Nov 3, 2010 at 11:07
  • We need more information, please show us your connection, and also a sample from your database structure as well as a few rows that can validate the data required is there. Commented Nov 3, 2010 at 11:21

4 Answers 4

2

Resolved! turns out when i imported from Excel to my mysql in brought in spaces after and before the "supp_short_code" so the query wasnt working!

Sign up to request clarification or add additional context in comments.

1 Comment

You can use MySQL TRIM() function for this, for example INSERT INTO myTabe (number, string) VALUES (12, TRIM(" something ")) - it will store the string without whitespaces before and after first/last characters.
1

Is 'supp_name' a column of your 'suppliers' table?

Does this query return any result under phpmyadmin eg?

Are the <p> tags displayed (no rules as display:none;)?

2 Comments

Weirdly this works SELECT * FROM suppliers WHERE supp_short_code LIKE '%WED%' but not "=WED" i can see the supp_short_code is definitely WED, unless its counting spaces because there might be a space after "WED " in the db!?
@user478144: that means that the exact string 'WED' is not stored in your table. You likely have some space characters. Try the query with TRIM(supp_short_code)='WED' and see what happens.
0

Where is your connection? If there isn't one, mysql_query() tries to make one by calling mysql_connect() with no args. It also fails if your connection doesn't have permissions for the table you're trying to read. If it's not dying but only returning no result, then check mysql_num_rows()

Comments

0

correct quotes of this line :: $result1 = mysql_query("select * from suppliers where supp_short_code='WED'") or die(mysql_error());

Comments

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.