•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 428,629 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,963 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1790 | Replies: 21 | Solved
![]() |
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 175
Reputation:
Rep Power: 1
Solved Threads: 2
php Syntax (Toggle Plain Text)
<?php // connection to MySQL server mysql_connect('localhost','root','root'); mysql_select_db('administration'); // *** Validate request to login to this site. //session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; //$MM_fldUserAuthorization = "level_usr"; $MM_redirectLoginSuccess = "validated.php"; $MM_redirectLoginFailed = "index.html"; $MM_redirecttoReferrer = true; //mysql_select_db($database_connBlog, $connBlog); mysql_select_db($database, $administration); $LoginRS__query=sprintf("SELECT username, password FROM adminprofile WHERE username='%s' AND password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $adminprofile) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { // $loginStrGroup = mysql_result($LoginRS,0,'level_usr'); //declare two session variables and assign them // $GLOBALS['MM_Username'] = $loginUsername; //$GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables //session_register("MM_Username"); //session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?>
errors:
1.Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in D:\xampp\htdocs\cycle\validate.php on line 34
2.Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\xampp\htdocs\cycle\validate.php on line 38
Please help as I couldn't make the code to check my username and password from the login page and validate it with the information stored in the database.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
On line 23,
If administration is the database name, you should give,
Read more on mysql_select_db here.
mysql_select_db($database, $administration); What are you trying to do ? If administration is the database name, you should give,
mysql_select_db('administration'); Read more on mysql_select_db here.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 175
Reputation:
Rep Power: 1
Solved Threads: 2
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
You dont need $adminprofile. mysql_query takes 2 parameters. 1. The query and 2. The connection resource. The second one is optional.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 175
Reputation:
Rep Power: 1
Solved Threads: 2
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
The syntax isnt wrong. Print whats in $MM_redirectLoginSuccess and $MM_redirectLoginFailed. Header function fails if you are outputting ANYTHING before calling a header function.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 175
Reputation:
Rep Power: 1
Solved Threads: 2
php Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Cycle Tracks Portal - Validation Page</title> <style type="text/css" media="all">@import "images/style.css"; </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" /> </head> <body> <?php // connection to MySQL server mysql_connect('localhost','root','root'); mysql_select_db('administration'); // *** Validate request to login to this site. //session_start(); if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_redirectLoginSuccess = "validate.php"; $MM_redirectLoginFailed = "index.html; $MM_redirecttoReferrer = true; mysql_select_db('administration'); $LoginRS__query=sprintf("SELECT username, password FROM adminprofile WHERE username='%s' AND password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } ?> </body> </html>
This my new set of codes. now the error at line "28".It says that,
"Parse error: syntax error, unexpected T_STRING in D:\xampp\htdocs\cycle\validate.php on line 28"
Last edited by lordx78 : Feb 6th, 2008 at 11:14 am.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
php Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Cycle Tracks Portal - Validation Page</title> <style type="text/css" media="all">@import "images/style.css"; </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" /> </head> <body> <?php // connection to MySQL server mysql_connect('localhost','root','root'); mysql_select_db('administration'); // *** Validate request to login to this site. //session_start(); if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_redirectLoginSuccess = "validate.php"; $MM_redirectLoginFailed = "index.html"; $MM_redirecttoReferrer = true; mysql_select_db('administration'); $LoginRS__query=sprintf("SELECT username, password FROM adminprofile WHERE username='%s' AND password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } ?> </body> </html>
There was a missing ".
Last edited by nav33n : Feb 6th, 2008 at 12:00 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 175
Reputation:
Rep Power: 1
Solved Threads: 2
php Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Cycle Tracks Portal - Validation Page</title> <style type="text/css" media="all">@import "images/style.css"; </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" /> </head> <body> <?php // connection to MySQL server mysql_connect('localhost','root','root'); mysql_select_db('administration'); // *** Validate request to login to this site. //session_start(); if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_redirectLoginSuccess = "validate.php"; $MM_redirectLoginFailed = "index.html; $MM_redirecttoReferrer = true; mysql_select_db('administration'); $LoginRS__query=sprintf("SELECT username, password FROM adminprofile WHERE username='%s' AND password='%s'"); get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } ?> </body> </html>
Sorry it was a paste mistake. The previous error was still there even though the code has been corrected. pls help.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
line 24. $MM_redirectLoginFailed = "index.html; <<< you haven't closed it.
It should have been
$MM_redirectLoginFailed = "index.html";
Use the code that I have posted in previous post. I guess it will work. Your new modified code has a different select query !
It should have been
$MM_redirectLoginFailed = "index.html";
Use the code that I have posted in previous post. I guess it will work. Your new modified code has a different select query !
Last edited by nav33n : Feb 6th, 2008 at 12:02 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- login page (ASP.NET)
- Error in mailer script (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP & Forms & Textarea
- Next Thread: unset $_SERVER['PHP_AUTH_USER']



Linear Mode