Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 12-05-2004, 11:40 AM   #11
In Runtime
Windwaker222's Avatar
Join Date: Nov 2004
Posts: 351

yea that would be it

AMD Phenom 9600 / 4GB OCZ Gold / nVidia 8800GT / ASUS Crosshair 4xPCI-E
Windwaker222 is offline   Reply With Quote
Old 12-05-2004, 11:44 AM   #12
pcmxkeith's Avatar
Join Date: Dec 2004
Posts: 842
Send a message via AIM to pcmxkeith Send a message via MSN to pcmxkeith Send a message via Yahoo to pcmxkeith
Default Re: php/mysql error

Whats the purpose of this site? Might i ask

pcmxkeith is offline   Reply With Quote
Old 12-05-2004, 06:03 PM   #13
In Runtime
Windwaker222's Avatar
Join Date: Nov 2004
Posts: 351

nothing yet, its gonna be reviews on tech stuff, forum, possibly blog, ive got a lot of ideas that i need to sort out
AMD Phenom 9600 / 4GB OCZ Gold / nVidia 8800GT / ASUS Crosshair 4xPCI-E
Windwaker222 is offline   Reply With Quote
Old 12-07-2004, 01:40 PM   #14
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 7,872
Default Re: php/mysql error

I have two suggestions...

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

I think the connecting string to the database might be wrong.
try changing the commenting part of your script.
               $conn = mysql_connect($host, $db_username, $db_password);
               $db = mysql_select_db($db_name, $conn) or
               print ("We are currently having troubles with the database.  Sorry for the inconvenience.  Please try again later.");
               $query = "SELECT * FROM login WHERE username LIKE '$username' AND password LIKE '$password'";   
               $result = mysql_query($query);
               $numrow = mysql_num_rows($result, $db);
               if ($numrow==1) {
               print ("You have succesfully loged in as $username");
               print ("There has been no account found under this name.  Please check for spelling and try again.");
               echo("Please Log-In to continue...<br>
               <form method=\"post\" action=\"login.php\">
               <input type=\"text\" name=\"username\" /><br>
               <input type=\"password\" name=\"password\" /><br>
               <input type=\"submit\" value=\"submit\" name=\"submit\" />
the variable $conn is a pointer to the database connection, and needs to be included when selecting the database. $db is a pointer to the selected database on the server. (though I'm not sure about that one as I've not used it in my second suggestion.

the second suggestion is a different way of looking at the situation.
$uname = $_POST['uname'];
$pass = $_POST['pwd'];

$myServer = "localhost"; 
$myUser = "xxx"; 
$myPass = "xxx"; 
$myDB = "database"; 
$s = @mssql_connect($myServer, $myUser, $myPass) 
or die("Couldn't connect to SQL Server on $myServer"); 

$d = @mssql_select_db($myDB, $s) 
or die("Couldn't open database $myDB");
//connect to database and check passwaord username combination and get permissions

$query = "SELECT * from users where username = '$uname' and password = '$pass'";
$result = mssql_query($query);
while ( $row = mssql_fetch_array($result) )
$permissions =$row["permissions"];

$_SESSION['user_name'] = $uname;
$_SESSION['permission'] = $permissions;
     if ((isset($_SESSION['user_name']))&&(isset($_SESSION['permission']))) {
     echo "<br>you have sucessfully logged in as: ".$_SESSION['user_name'];
     echo '<br><br><br><a href="default.php">If you are not redirected automaticaly please follow this link</a>';

echo 'You did not log in sucessfully please try again.

<form method=post action=login.php>
<input type="text" name="uname" id="uname"><br>
<input type="password" name="pwd" id="pwd"><br>
<input type="submit" value="Log In">
Alternativly, if you havn\'t got a log in name you can <a href=applymember.php>apply for membership.</a>
You make sure that there is only one instance of each username on registration, so you can afford to ignore that (if $num_rows = "1") statement, because a user either exists, (with one instance) or doesn't exist, (with no instances.
when the ser logs on they have a permission selected from a database (this would be checked to find out what actions they can perform, (eg, user or admin) and if the user exists, the permission level and the username are stored in a session variable.

session variables are server side, so the user doesnot hae to have cookies, also storing the permission level (and any other usefull information) will reduce the amount of database queries needed (and help improve performance).

hope this helps...

root is offline   Reply With Quote

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 05:13 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0