Author Topic: accidently put this in wrong board Help with error . Not sure of prob  (Read 841 times)

0 Members and 1 Guest are viewing this topic.

Offline valwardonTopic starter

  • Irregular
  • Posts: 6
    • View Profile
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

Quote
<?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?
« Last Edit: March 04, 2008, 10:38:15 AM by fenway »

Offline AndyB

  • back from the North Pole ... and retired!
  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,521
  • php 5.2.3 / MySQL 5.0.27
    • View Profile
    • halfadot smallwebs
Re: accidently put this in wrong board Help with error . Not sure of prob
« Reply #1 on: March 02, 2008, 09:53:21 AM »
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.
Legend has it that reading the manual never killed anyone.
My site

Offline valwardonTopic starter

  • Irregular
  • Posts: 6
    • View Profile
Re: accidently put this in wrong board Help with error . Not sure of prob
« Reply #2 on: March 02, 2008, 10:13:35 AM »
Error: No database selected with query select * from admin where user='user' and pass='pass'

I think I am getting closer
« Last Edit: March 02, 2008, 10:14:21 AM by valwardon »

Offline valwardonTopic starter

  • Irregular
  • Posts: 6
    • View Profile
Re: accidently put this in wrong board Help with error . Not sure of prob
« Reply #3 on: March 02, 2008, 10:28:06 AM »
what does that mean no database selected

Offline AndyB

  • back from the North Pole ... and retired!
  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,521
  • php 5.2.3 / MySQL 5.0.27
    • View Profile
    • halfadot smallwebs
Re: accidently put this in wrong board Help with error . Not sure of prob
« Reply #4 on: March 02, 2008, 10:40:44 AM »
what does that mean no database selected

That either mysql_select_db($database, $db_conn); never executed or that $database is undefined ...
Legend has it that reading the manual never killed anyone.
My site

Offline valwardonTopic starter

  • Irregular
  • Posts: 6
    • View Profile
Re: accidently put this in wrong board Help with error . Not sure of prob
« Reply #5 on: March 02, 2008, 10:44:10 AM »
here is where i defined my data base.

Code: [Select]
<?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
Code: [Select]
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
 
 
 
 

« Last Edit: March 04, 2008, 10:38:48 AM by fenway »