valwardon Posted March 2, 2008 Share Posted March 2, 2008 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fehsetfc/public_html/user/admin/index.php on line 19 than when i open that file this is what it says <?PHP session_start(); include "../../affconfig.php"; include "../lang/$language"; if ($_POST['userid']!='' && $_POST['password']!='') { // protection against script injection $userid = preg_replace('/[^a-zA-Z0-9_]/', '', $_POST['userid']); $password = preg_replace('/[^a-zA-Z0-9_]/', '', $_POST['password']); // if the user has just tried to log in $db_conn = mysql_connect($server, $db_user, $db_pass) or die ("Database CONNECT Error (line 11)"); mysql_select_db($database, $db_conn); $query = "select * from admin where user='$userid' and pass='$password'"; $result = mysql_query($query, $db_conn); if (mysql_num_rows($result) >0 ) { // if they are in the database register the user id $_SESSION['aff_valid_admin'] = $userid; // logout user if he was logged in before $_SESSION['aff_valid_user'] = ''; unset($_SESSION['aff_valid_user']); echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=0;URL=index2.php>"; exit; } } include "header.php"; if(aff_admin_check_security()) { aff_redirect('index2.php'); exit; } else { if (isset($_POST['userid'])) { // if they've tried and failed to log in echo AFF_I_CANNOTLOG; } else { // they have not tried to log in yet or have logged out echo AFF_I_NOTLOGGED; } // provide form to log in ?> <form method=post action="index.php"> <table align=center border=0> <tr><td><?=AFF_G_USERNAME?>:</td> <td><input type=text name=userid></td></tr> <tr><td><?=AFF_G_PASSWORD?>:</td> <td><input type=password name=password></td></tr> <tr><td colspan=2 align=center> <input type=submit value="Log in"></td></tr> </table></form> <? } ?> </p> <?PHP include "footer.php"; ?> Does anyone know what is wrong? Link to comment https://forums.phpfreaks.com/topic/94009-accidently-put-this-in-wrong-board-help-with-error-not-sure-of-prob/ Share on other sites More sharing options...
AndyB Posted March 2, 2008 Share Posted March 2, 2008 try using this in place of what you have: $result = mysql_query($query, $db_conn) or die("Error: ". mysql_error(). " with query ". $query); // helpful error message That may shed some light on your troubles. Link to comment https://forums.phpfreaks.com/topic/94009-accidently-put-this-in-wrong-board-help-with-error-not-sure-of-prob/#findComment-481620 Share on other sites More sharing options...
valwardon Posted March 2, 2008 Author Share Posted March 2, 2008 Error: No database selected with query select * from admin where user='user' and pass='pass' I think I am getting closer Link to comment https://forums.phpfreaks.com/topic/94009-accidently-put-this-in-wrong-board-help-with-error-not-sure-of-prob/#findComment-481634 Share on other sites More sharing options...
valwardon Posted March 2, 2008 Author Share Posted March 2, 2008 what does that mean no database selected Link to comment https://forums.phpfreaks.com/topic/94009-accidently-put-this-in-wrong-board-help-with-error-not-sure-of-prob/#findComment-481644 Share on other sites More sharing options...
AndyB Posted March 2, 2008 Share Posted March 2, 2008 what does that mean no database selected That either mysql_select_db($database, $db_conn); never executed or that $database is undefined ... Link to comment https://forums.phpfreaks.com/topic/94009-accidently-put-this-in-wrong-board-help-with-error-not-sure-of-prob/#findComment-481651 Share on other sites More sharing options...
valwardon Posted March 2, 2008 Author Share Posted March 2, 2008 here is where i defined my data base. <?PHP //------------------------------------------------------------------------------- // CONFIGURATION OPTIONS //------------------------------------------------------------------------------- // Your domain name (include www. if used BUT NOT http://) $domain = "www.freshsitetraffic.com"; // Your MySQL server address (usually 'localhost') $server = "localhost"; // Your MySQL database username $db_user = "****"; // Your MySQL database password $db_pass = "****"; // Your MySQL database name $database = "****"; // The currency that your affiliates will be paid in $currency = "US Dollars"; // Your email address $emailinfo = "****"; // Your sites name $yoursitename = "Fresh Site Traffic"; // language of control panel (only eng.php so far) $language = "eng.php"; // cookie expiration in days. If 0, it is "unlimited" (set to 10 yrs) $cookieExpiration = 0; // cookie path, should be always '/' $cookiePath = '/'; // you can set it to '.yourdomain.com' if you wnt cookie // to be available also on subdomains $cookieDomain = ''; // whether to display debug message during sale registration // activate it by setting it to true $debugMessage = false; //------------------------------------------------------------------------------- // DO NOT MODIFY ANYTHING BELOW THIS POINT UNLESS // YOU KNOW WHAT YOU ARE DOING //------------------------------------------------------------------------------- $clientdate = (date ("Y-m-d")); // Do Not Touch $clienttime = (date ("H:i:s")); // Do Not Touch $clientbrowser = getenv("HTTP_USER_AGENT"); // Do Not Touch $clientip = $HTTP_SERVER_VARS['REMOTE_ADDR']; // Do Not Touch $clienturl = getenv("HTTP_REFERER"); // Do Not Touch // helper functions function aff_check_security() { if(!isset($_SESSION['aff_valid_user']) || $_SESSION['aff_valid_user']=='') return false; else return true; } function aff_admin_check_security() { if(!isset($_SESSION['aff_valid_admin']) || $_SESSION['aff_valid_admin']=='') return false; else return true; } function aff_redirect($url, $time = 0) { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"$time;URL=$url\">"; echo "If you will be not redirected within few seconds click <a class=leftLink href=$url>".here.'</a>'; } ?> as far as getting it to exicute im not sure how to do that part.on my account maintance screen this message is there next to my data bass right under my username Connection Strings Perl $dbh = DBI->connect("DBI:mysql:f****:localhost","****","<PASSWORD HERE>"); PHP $dbh=mysql_connect ("localhost", "****", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("****"); here is the full page MySQL Account Maintenance -------------------------------------------------------------------------------- Current Databases: **** Users in dmname **** (Privileges: ALL PRIVILEGES) Connection Strings Perl $dbh = DBI->connect("DBI:mysql:****:localhost","****","<PASSWORD HERE>"); PHP $dbh=mysql_connect ("localhost", "****", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("****"); New Database: -------------------------------------------------------------------------------- Current Users: **** Username: Password: -------------------------------------------------------------------------------- Add Users To Your Databases: User: **** Database: **** Privileges: ALL or SELECT CREATE INSERT ALTER UPDATE DROP DELETE LOCK TABLES INDEX REFERENCES CREATE TEMPORARY TABLES -------------------------------------------------------------------------------- Access Hosts: localhost Host (% wildcard is allowed): -------------------------------------------------------------------------------- phpMyAdmin You can use phpMyAdmin to administer your MySQL databases in a web based environment. [ Go Back ] mod-edit: user's information removed and replaced with **** for security Link to comment https://forums.phpfreaks.com/topic/94009-accidently-put-this-in-wrong-board-help-with-error-not-sure-of-prob/#findComment-481653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.