Jump to content

Recommended Posts

Can someone show me what is wrong here line 15 is $result = mysql_query("Select * From login_table where user_name='$username';

 

Parse error: syntax error, unexpected ')' in /home/public_html/App/Admin/login.php on line 15

 

if (isset($_POST['Submit']))
{

$username = $_POST['username'];
$password = md5($_POST[password]);

mysql_connect($dbServer, $dbUsername, $dbPassword)){
$result = mysql_query("Select * From login_table where user_name='$username';

if(mysql_num_rows($result)>0)
{
	$row = mysql_fetch_array($result, MYSQL_BOTH);
	if($password == $row["user_pass"])
	{

		$_SESSION['loginok'] = "ok";
		$_SESSION['username'] = "username";
		$_SESSION['password'] = "password";
		$_SESSION['level'] = $row["user_level"];

 

Link to comment
https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/
Share on other sites

mysql_query("Select * From login_table where user_name='$username';

 

 

Should be

 

 

mysql_query("Select * From login_table where user_name='$username'");

 

 

 

And

 

 

mysql_connect($dbServer, $dbUsername, $dbPassword)){

 

 

That's not valid syntax.

seems thats fix but now I get this

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/App/Admin/login.php on line 18 ***if(mysql_num_rows($result)>0)

 

if (isset($_POST['Submit']))
{

$username = $_POST['username'];
$password = md5($_POST[password]);

mysql_connect($dbServer, $dbUsername, $dbPassword);
$result = mysql_query("Select * From login_table where user_name='$username'");

if(mysql_num_rows($result)>0)
{
	$row = mysql_fetch_array($result, MYSQL_BOTH);
	if($password == $row["user_pass"])
	{

		$_SESSION['loginok'] = "ok";
		$_SESSION['username'] = "username";
		$_SESSION['password'] = "password";
		$_SESSION['level'] = $row["user_level"];

seems thats fix but now I get this

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/App/Admin/login.php on line 18 ***if(mysql_num_rows($result)>0)

 

if (isset($_POST['Submit']))
{

$username = $_POST['username'];
$password = md5($_POST[password]);

mysql_connect($dbServer, $dbUsername, $dbPassword);
$result = mysql_query("Select * From login_table where user_name='$username'");

if(mysql_num_rows($result)>0)
{
	$row = mysql_fetch_array($result, MYSQL_BOTH);
	if($password == $row["user_pass"])
	{

		$_SESSION['loginok'] = "ok";
		$_SESSION['username'] = "username";
		$_SESSION['password'] = "password";
		$_SESSION['level'] = $row["user_level"];

 

 

if(mysql_num_rows($result)>0)

 

since it's for a user try this:

 

if ( mysql_num_rows ($result) == 1 )

OR

if ( mysql_num_rows ($result) != 0 )

change

$result = mysql_query("Select * From login_table where user_name='$username'");

to

$result = mysql_query("Select * From login_table where user_name='$username'") or die(mysql_error());

I get error could not select database. so from the above code I added

mysql_connect($dbServer, $dbUsername, $dbPassword, $dbDatabase);

but still didnt work

 

try a diffrent database connection code as your's is all flash.

<?php
$db=mysql_connect("localhost","username","password");
$res=mysql_select_db("database_name",$db)or die('database connection error'.mysql_error());
?>

 

You was crawling before walking when you grow up, i guess.

 

Never go above your head, unless you no what your doing.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.