Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HELP!!! Please. I can't connect my Script to SQL!

Author  Topic 

CuBz
Starting Member

1 Post

Posted - 2007-01-24 : 05:43:36
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:

[bWarning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/cubz.awardspace.com/index.php on line 95

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/www/cubz.awardspace.com/index.php on line 96


Here is the script:

<?php
session_start();
include_once"includes/db_connect.php";
if (strip_tags($_GET['logout']) == "yes"){
session_destroy();
}elseif (isset($_SESSION['username'])){
header("Location: Pick.php");
exit();
}

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"){
include_once"dead.php";
exit();

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

}

session_register('username');
$_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 />";

}}}
?>




<?php
$banned_ip = array();
$banned_ip[] = '111.111.111.110'; // first IP
$banned_ip[] = '111.111.111.111'; // second IP
$banned_ip[] = '111.111.111.112'; // 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";
exit();
}
}

// The rest of your PHP script goes here
?>





<?
$timenow=time();
$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;
}
document.onmousedown=right;
</script>




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

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



<tr>
<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>
</tr>
<tr>
<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" />
</p>

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

Please help :D

I AM NEW! HELP!!!!!

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-24 : 05:49:17
This forum is for posting SQL Server questions. Post MySQL related questions on some other site like www.dbForums.com or forums.mysql.com.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -