-1

please help me repair this error..

<?php echo "<h3>Accounts</h3><table style=\"margin-top:10px;text-align:center;\" width=\"65%\"  cellspacing=\"0\" cellpadding=\"5\" align=\"center\">"; ?>
    <?php
    $accq = mysql_query("SELECT * FROM accounts ORDER BY username DESC");
    while ($acc = mysql_fetch_array($accq))
    {
    echo "<tr style=\"background:#D16976;color:#fff;\"><td><font size=\"1\">$acc[username]</font></td></tr><tr><td>$acc[password]</td></tr><td height=\"10\" ></td>";
    }
    echo "</table>"; 
    echo "<br>Error: ";
    $result = mysql_query($accq) or die (mysql_error());

    ?>

and im getting:
http://s8.postimg.org/9o0blstnp/screenshot_1134.png

  • 1
    Please look into using mysqli or PDO for database connections etc, much safer! Mysql_* functions are becoming deprecated – Andy Holmes Dec 17 '13 at 21:26
  • 3
    Read your code: `$accq = mysql_query(...)` ... `$result = mysql_query($accq)` -- notice the error? :) – Amal Murali Dec 17 '13 at 21:27
  • @Amal Murali, i wrote that code to see why im getting the error you see in my screen. – user3112931 Dec 17 '13 at 21:32
  • *please help me repair this error."* `+` *"i wrote that code to see why im getting the error you see in my screen."* = `$confused->yes_I_am;` – Funk Forty Niner Dec 17 '13 at 21:36
  • ?? :D ,i wrote that code ($result) to see why am i getting boolean.... , so im getting that boolean....., because query was empty.. so why my query was empty? – user3112931 Dec 17 '13 at 21:39

1 Answers1

0

Your problem is you have not created the connection to your database.
When there is no database connection available, there is nothing that your available can do about send/retrieve data from any table in your database.
If you do not know how to create a connection to DB, simply search on internet and you will be drown in tutorials showing you how to do it.
Also, try to avoid using mysql_* function since they have been deprecated.

Justin
  • 187
  • 1
  • 15
  • require "../system/db.php"; ?> – user3112931 Dec 17 '13 at 21:41
  • did you test your SQL code in phpMyAdmin? if it works in there, that must be your connection with the problem. – Justin Dec 17 '13 at 21:44
  • oh... fu^& me, my wamp didnt have (without php) active.. – user3112931 Dec 17 '13 at 21:44
  • ok thanks (it works).. now what can i put instead of mysql_fetch_array – user3112931 Dec 17 '13 at 21:46
  • when you use msqli, then you will have to modify some other functions as well like msql_query(); to mysqli_query(); you can find the replacement at php.net for every deprecated function. if you are using mysql_* then yes you can use it without changing. – Justin Dec 17 '13 at 21:48