If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Connectin Script to SQL! HOW?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-24-07, 06:04
CuBz CuBz is offline
Registered User
 
Join Date: Jan 2007
Posts: 1
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/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>


Please help
Reply With Quote
  #2 (permalink)  
Old 01-24-07, 10:38
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
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
Reply With Quote
  #3 (permalink)  
Old 01-24-07, 11:34
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,259
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On