Jump to content

SQL connection and select error


big-dog1965

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

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.