Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007

    Unanswered: Connectin Script to SQL! HOW?

    I have made a table in MySQL for he user and pass and i knew how to do that i just don't know how to connect my script to that table :s

    This message shows when i try to go on it:

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/ on line 95

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/www/ on line 96

    Here is the script:

    if (strip_tags($_GET['logout']) == "yes"){
    }elseif (isset($_SESSION['username'])){
    header("Location: Pick.php");

    if ($_POST['Submit'] && strip_tags($_POST['username']) && strip_tags($_POST['password'])){
    $username = addslashes(strip_tags($_POST['username']));
    $password = addslashes(strip_tags($_POST['password']));

    $ip = $REMOTE_ADDR;

    ///check INFO

    $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1' LIMIT 1");

    $login_check = mysql_num_rows($sql);
    $inf = mysql_fetch_object($sql);
    if ($login_check == "0"){
    $message="You could not be logged in";
    }elseif ($login_check != "0"){

    if ($login_check > "0"){
    if ($inf->status == "Dead"){

    if ($inf->status == "Banned"){
    header("Location: banned.php?banned=$username&encoded=$encoded");


    $_SESSION['username'] = $inf->username;

    $timestamp = time()+60;
    mysql_query("UPDATE users SET online='$timestamp' WHERE username='$username'");

    mysql_query("UPDATE users SET l_ip='$ip' WHERE username='$username'");

    header("Location: Pick.php");

    } else {
    $message= "Incorrect Username or Password<br />";


    $banned_ip = array();
    $banned_ip[] = ''; // first IP
    $banned_ip[] = ''; // second IP
    $banned_ip[] = ''; // third IP, just add more if you need

    foreach($banned_ip as $banned) {
    $ip = $_SERVER['REMOTE_ADDR'];
    if($ip == $banned){
    echo "<b>You have been IP banned! You Broke the ML Rules";

    // The rest of your PHP script goes here

    $select = mysql_query("SELECT * FROM users WHERE online > '$timenow' ORDER by id");
    $num = mysql_num_rows($select);
    while ($i = mysql_fetch_object($select))
    <script language="JavaScript">
    function right(e) {
    if (navigator.appName == 'Netscape' &&
    (e.which == 3 || e.which == 2))
    return false;
    else if (navigator.appName == 'Microsoft Internet Explorer' &&
    (event.button == 2 || event.button == 3)) {
    alert("Right Click Disabled.");
    return false;
    return true;

    <link href="main.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    .style4 {font-size: 12px}
    .style7 {font-size: xx-large}
    <title>A Mafia Life | Please Login</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <body bgcolor="#555555" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <div align="center">

    <form name="form1" method="post" action="">
    <img src="banner1.jpg"><br>
    <td> </td>
    <table width="600" border="1" cellspacing="0" bordercolor="#000000" bgcolor="#666666">

    <td><a href="index.html"><img src="../mafia/game images/images/Login_01.gif" width="190" height="70" border="0"></a><a href="register.php"><img src="../mafia/game images/images/Login_02.gif" width="219" height="70" border="0"></a><a href="fpass.php"><img src="../mafia/game images/images/Login_03.gif" width="198" height="70" border="0"></a><a href="story.php"><img src="../mafia/game images/images/Login_04.gif" width="203" height="70" border="0"></a><a href="faq.php"><img src="../mafia/game images/images/Login_05.gif" width="214" height="70" border="0"></a></td>
    <td align="center" valign="top" bgcolor="#999999"><p class="style4"><br />

    <font color=darkred size=5><b><center></center><b></font><br />
    <br />

    <img src="../mafia/game images/username.jpg" width="150" height="25" alt="UserName">
    <input name="username" type="text" id="username" value="" size="30" maxlength="40" />
    <br />
    <br />
    <img src="../mafia/game images/Password.jpg" width="150" height="25" alt="Password">
    <input name="password" type="password" id="password2" value="" size="30" maxlength="40" />
    <br />
    <br />
    <input type="submit" name="Submit" value="Login" />

    <table width="136" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor=black class="thinline">
    <td height="27" background="includes/grad.jpg"><center>
    Total Online
    <td height="41" bgcolor="666666"><div align="center"><font color="#ffffff"><?php echo "$num"; ?></font> </div></td>
    <p class="style4"><br />
    <th height="23" scope="row" bgcolor="#666666"><p> </p></th>
    <th height="22" scope="row" bgcolor="#666666"><p><center>
    <!-- End ImageReady Slices -->

    Please help

  2. #2
    Join Date
    Mar 2004
    Some help:

    1) use [php ] and [/php] tags (without the space in my first tag), to highlight your php code
    2) Post only the relevant part of your code.
    3) search a) this forum or b) the web to see what your error code means

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    have you looked at the PHP site on how to use MySQL within PHP

    it also depends on which version of PHP you are usingn.. the old style MySQL functions are depracted in favour of the MySQLi in PHP 4.1 and above

    agree with quelphdad, there is little point in posting the whole of your script, just the pertinent lines. Its doubtfull people are going to wade through a script to find the 94th line.. if you provide the snipped code its more likely to get an answer.

    it may also help posting this sort of question int he PHP thread on this forum.. as its not a MySQL Isssue
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts