Page 2 of 2

Posted: Wed Mar 17, 2004 9:45 pm
by Illusionist
hmmm..... are you going to maek us guess at what line 9 is??

Posted: Wed Mar 17, 2004 9:45 pm
by tim
SilverMist wrote:It says Parse Error, Line 9. Possibly from the quotations?
seeing some of the final code your using that is generating the error would possibly be helpful.

Posted: Wed Mar 17, 2004 9:45 pm
by timhortons
Well, the new releases have changed to $_GET/$_POST and whatnot, and scripts should be written with those instead, but I mean, when i was learning PHP i didnt wanna tinker with all my get/post variables :P

Nevermind me! just voicing an irrelevant personal opinion obviously.

Posted: Wed Mar 17, 2004 9:48 pm
by SilverMist
I am using Goowe's (sp?) code. Unfortunately now it is informing me that my table does not exist. However my table would have to exist in order to register!

Posted: Wed Mar 17, 2004 9:49 pm
by Goowe
I edited it and it should work now. The posts came so fast after I told you.

Code: Select all

<?php
$host = "localhost";
$dbusername = "user";
$password = "pass";
$database = "db";

// Connect to mysql and database
$link = mysql_connect($host, $dbusername, $password)
	or die("<P>Could not connect: ".mysql_error()."</P>");
mysql_select_db($database) 
	or die("<P>Could not select database</P>");                   

$username = $HTTP_POST_VARS['txtName'];
$password = $HTTP_POST_VARS['txtPassword'];

$query = "SELECT * FROM Members WHERE Name = '".$username."' AND Password = '".$password."'";
$result = mysql_query($query) or die("<P>Query failed: ".mysql_error()."</P>");

// Check to see if user exists
if(mysql_num_rows($result) > 0)
{
	// Make cookie for user
	if(setcookie("loginname", $username))
	{
		echo "Welcome";
	}
		else
	{
		echo "Error setting cookie.";
	}
}
	else
{
	echo "Failed login.";
}
?>

Posted: Wed Mar 17, 2004 9:56 pm
by SilverMist
Still doesn't work :'(

Posted: Wed Mar 17, 2004 9:56 pm
by Goowe
*sneeze*

What is the error? No table there?

Posted: Wed Mar 17, 2004 10:00 pm
by SilverMist
Yep still getting that error :cry:

Posted: Wed Mar 17, 2004 10:01 pm
by Goowe

Code: Select all

<?php
$query = "SELECT * FROM Members WHERE Name = '".$username."' AND Password = '".$password."'";
?>
Since I'm not the person who wrote your original code, I don't know what the name of your table really is. Make sure in your mySQL database that the table that holds the user information is entitled "Members" and nothing else. If it's something different, you'll have to change the "Members" part in the code above to the exact name of the table.

Posted: Wed Mar 17, 2004 10:06 pm
by SilverMist
Wait...then I'd have to split up my code. Would I be able to do that?

Posted: Wed Mar 17, 2004 10:07 pm
by Goowe
Sorry, I'm now considered confused :oops: Can you explain what you're questioning?

Posted: Thu Mar 18, 2004 6:11 am
by Illusionist
SilverMist wrote:Wait...then I'd have to split up my code. Would I be able to do that?
spilt up your code?? All you ahve to do is make sure your actually SELECTing fromt he right table.... "Members" change to whatever the real table's name is