By Dan Silver on
Hello,
I am currently in the proccess of making a module and when I copied it to a new site, none of the sql worked. So, I made a short test sql module just to test the database.
Here is part of the code for the test sql module:
function sql_test() {
$sql = 'SELECT * FROM {message} LIMIT 0, 30 ';
$result = mysql_query($sql);
$page_content = '';
while ($row = mysql_fetch_assoc($result)) {
$page_content .= $row['key'] . '<br>';
}
return $page_content;
}
When I go to the page I get this error:
* warning: mysql_query() [function.mysql-query]: Access denied for user 'silverho'@'localhost' (using password: NO) in /home3/silverho/public_html/futuremessage/modules/SQL Test/sqltest.module on line 17.
* warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home3/silverho/public_html/futuremessage/modules/SQL Test/sqltest.module on line 17.
* warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home3/silverho/public_html/futuremessage/modules/SQL Test/sqltest.module on line 19.
Any advice would be helpful!
Thank you!
Comments
=-=
I'm certainly no expert but I believe you have to call SQL in drupal using drupal's functions. see: api.drupal.org
for example: http://api.drupal.org/api/function/db_query/6
oh, thats wierd because I was
oh,
thats wierd because I was able to do it this way in the module I made before, and it worked fine. Thanks for the link, I will check it out.
I got it all worked out now.
I got it all worked out now. Thanks for help.