darkfreaks Posted December 29, 2008 Share Posted December 29, 2008 ok so this function is giving me this. Warning: mysql_query() [function.mysql-query]: Access denied for user 'kabooc'@'localhost' (using password: NO) in /home/kabooc/public_html/func.lib.php on line 5 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kabooc/public_html/func.lib.php on line 5 the code is: <?php function fetch($query) { return mysql_query(mysql_fetch_array($query)); }?> any help debugging this would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/ Share on other sites More sharing options...
premiso Posted December 29, 2008 Share Posted December 29, 2008 Read the error. You need to make sure you have permissions setup for the user kabooc not using a password on your mysql database. It is not the function at all. Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725483 Share on other sites More sharing options...
darkfreaks Posted December 29, 2008 Author Share Posted December 29, 2008 that user has all permissions for that database some of the other functions require config.inc.php to connect i tried that and it still threw the error which i believe it has to be the function. ??? Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725485 Share on other sites More sharing options...
Maq Posted December 29, 2008 Share Posted December 29, 2008 that user has all permissions for that database Are you sure? Cause that error usually means 1 thing... Could you log in to mysql with root and do "show users;" (or w/e the command is) and see if kabooc is set up with all privileges for your local server? Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725489 Share on other sites More sharing options...
premiso Posted December 29, 2008 Share Posted December 29, 2008 Does the query work outside of the "fetch" function you created? Before you use the "fetch" are you getting a good connection to the database. Honestly if the query works outside than you should try passing the dblink or making it global to the function and using that. But if the mysql_query does not work outside of the function the issue lies within your database username/password privileges. Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725490 Share on other sites More sharing options...
trochia Posted December 29, 2008 Share Posted December 29, 2008 1) Are you using a "canned script" (modules) for some of this? 2) Are you on a "shared" enviorment? 3) If you're uploading to #2, and you don't have the ability to "CHMOD", you'd run into this. 4) If you can't "change" r-w perm's w.it..this would possibly be it, again? Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725494 Share on other sites More sharing options...
premiso Posted December 29, 2008 Share Posted December 29, 2008 1) Are you using a "canned script" (modules) for some of this? 2) Are you on a "shared" enviorment? 3) If you're uploading to #2, and you don't have the ability to "CHMOD", you'd run into this. 4) If you can't "change" r-w perm's w.it..this would possibly be it, again? Hes not doing a file upload. He is just trying to query from his database.... Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725496 Share on other sites More sharing options...
darkfreaks Posted December 29, 2008 Author Share Posted December 29, 2008 this function worked fine until i used include_once to call another file. so something is messing it up. the script is global anyhow.ill have to find a way to rewrite it ugh. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725499 Share on other sites More sharing options...
Maq Posted December 29, 2008 Share Posted December 29, 2008 It should work. I use a class that I include in all my files. I create an object of that class that handles queries, connections etc... Yours should still work. Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725502 Share on other sites More sharing options...
premiso Posted December 29, 2008 Share Posted December 29, 2008 Look at the file you are including and see if you are resetting the mysql_connection in it, or if it is being reset. That is what seems to be happening imo. Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725505 Share on other sites More sharing options...
darkfreaks Posted December 29, 2008 Author Share Posted December 29, 2008 i see the problem in both scripts the connection variable is $con Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725511 Share on other sites More sharing options...
premiso Posted December 29, 2008 Share Posted December 29, 2008 could mysql_close($connection) kill it even if $connection is defined to another database. ??? Possibly, if you are using multiple connections, I would highly suggest using $connection in the mysql_query as the second parameter. <?php function fetch($query) { global $connection; return mysql_fetch_array(mysql_query($query, $connection)); }?> Also I just noticed that you had the fetch_array in the wrong spot, and also note that without the while loop this will only ever return the first array value. function fetch($query) { global $connection; $result = mysql_query($query, $connection); while ($row = mysql_fetch_array($result)) { $return[] = $row; } return $return; } That will return the multi-dimm array with the results. Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725513 Share on other sites More sharing options...
darkfreaks Posted December 29, 2008 Author Share Posted December 29, 2008 ok now i get "failed to open file no such file or directory on line 478" code: <?php $lines = file($inj_path . $file);?//line 478> Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725516 Share on other sites More sharing options...
premiso Posted December 29, 2008 Share Posted December 29, 2008 You need to post more code, but obviously the $inj_path. $file does not link to a file. Print it out and see what it contains and why it does not work. Without more code this would be impossible to debug. Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725519 Share on other sites More sharing options...
Maq Posted December 29, 2008 Share Posted December 29, 2008 If you want to switch databases, instead of closing the connection each time, just select a different one: mysql_select_db('new_db'); mysql_close(); //closes everything... don't specify a DB Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725521 Share on other sites More sharing options...
darkfreaks Posted December 29, 2008 Author Share Posted December 29, 2008 <?php $inj_path = ''; $file="exploits.txt"; $lines = file($inj_path . $file);//dont work ?> Quote Link to comment https://forums.phpfreaks.com/topic/138756-solved-function-not-working-right/#findComment-725522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.