Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Why does this not work? :(

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Why does this not work? :(

Postby Raisario » Tue Nov 26, 2002 4:32 pm

Again, dont mind me, I'm very noobish to PHP........ :oops:

Sample code:
-----------------------------------------------------------------------------
// sending query to database
$query_coupontypes = mysql_query ("SELECT coupon_id, percentage_discount, description FROM coupontypes");
$query_coupons = mysql_query ("SELECT status, purchase_amount, retailer_ordernum FROM coupons");
$query_user = mysql_query ("SELECT username FROM users ");

// displaying data on a table
while ( $a_row = mysql_fetch_array($query_coupontypes)) {
print "<TR align=center>";
print "<TD width=100> $a_row[coupon_id] </TD>";
print "<TD width=100> $a_row[percentage_discount] </TD>";
print "<TD width=100> $a_row[description] </TD>";
}
while ( $b_row = mysql_fetch_array($query_coupons)) {
print "<TD width=100> $b_row[status] </TD>";
print "<TD width=100> $b_row[purchase_amount] </TD>";
print "<TD width=100> $b_row[retailer_ordernum] </TD>";
}
while ( $c_row = mysql_fetch_array($query_users)) {
print "<TD width=100> $c_row[username] </TD><TR>";
-----------------------------------------------------------------------------

The middle WHILE statement works but the bottom and top doesnt...
I gives me 2 error message for both the top and bottom WHILE statements that looks like this:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /pub/www/htdocs/admin-b/coupons/Report2_basic.php on line 31

pls pls pls help.......
Raisario
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Nov 26, 2002 2:24 pm

Postby adelinewss » Tue Nov 26, 2002 6:41 pm

Seems like there is some thing wrong with your queries. To see what is the error generated by the database, include echo(mysql_error()); after each of the query. Hope this help.
adelinewss
New php-forum User
New php-forum User
 
Posts: 4
Joined: Thu Oct 24, 2002 6:20 pm
Location: Malaysia

Postby Raisario » Wed Nov 27, 2002 12:16 pm

Thank you, that helped me find out the errors, now this page is working :D
Raisario
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Nov 26, 2002 2:24 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.