[PHP][MySQL] select * from ...

0

Z góry mówię, że jestem big lame w php i proszę o łagodny wymiar kary :).

[code]<html>

<head> <title>Pobieranie danych z MySQL</title> </head> <body> <?php
$aDBLink = @mysql_connect( localhost, "sodax_test", "test" );

if ( mysql_select_db( "sodax_test", $aDBLink ) == True )

{
echo("connect ok");
}

echo("<br>witaj!<br><br>");

$aSQL = "select * from table";

$aQResult = mysql_query( $aSQL, $aDBLink );

if ( $aQResult == True )
{
echo("select ok

");
}
else
{
echo("select error

");
}

            while ( $aRow = mysql_fetch_array( $aQResult ) )
            {
                echo( "$aRow<br>" );
            }
            mysql_free_result( $aQResult );

?>

</body> </html> [/code]

co jest źle :(?

pojawia się błąd:

connect ok
witaj!

select error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sodax/domains/domena_serwera/public_html/index.php on line 32

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/sodax/domains/domena_serwera/public_html/index.php on line 36

0

Zamień

if ( $aQResult == True )

na

if ( mysql_num_rows($aQResult) > 0 )

i powinno być ok ;]

0

poza tym nie

echo( "$aRow" );

tylko print_r($aRow);


a jak funkcja zwraca wartość logiczną, to warunek budujesz nie tak
```php
if (funkcja() == true)

tylko

if (funkcja())

1 użytkowników online, w tym zalogowanych: 0, gości: 1