hi i was very interested in the code example of the tutorialon user authentication with mysql since i would like to create a portal application for my web sitehere is the code it always dies at the third line and says can't do it
<?
if($submit){
$db=mysql_connect("xxxxxx","xxxxxx","xxxxxx") or die ("cant connect");
mysql_select_db("techunit",$db) or die("cant change");
$result=mysql_query("SELECT * FROM user WHERE name='$username'",$db) or die ("cant do it");
while($row=mysql_fetch_array($result)){
if($row["password"]==$password){
printf("Successfully Logged IN!<a href='indexhigh.asp'>Enter</a>");
}
}
}
?>
any help would be appreciated thanks
Question about tutorial user authentication with Mysql
Moderator: General Moderators
try this instead:
also, is there an table anmed 'user'? Have you set $username to something at all? Just checking 
Code: Select all
<?php
if($submit){
$db=mysql_connect("xxxxxx","xxxxxx","xxxxxx") or die ("cant connect");
mysql_select_db("techunit",$db) or die("cant change");
$query = "SELECT * FROM user WHERE name='$username'";
$result=mysql_query($query) or die ("cant do it");
while($row=mysql_fetch_array($result)){
if($row["password"]==$password){
printf("Successfully Logged IN!<a href='indexhigh.asp'>Enter</a>");
}
}
}
?>tried code change same thing dies on cant do it query
hi really appreciate your quick reply unfortunatly code does same thing dies on the query for further explanation yes i have supplied a user table in the techunit database and i have filled in a row of data in the table so their will be a name and password already enetered to match up with the entry
solved original code worked when i allowed select access
hi once i used mysql_error() instead of cant do it code explained i did not have select permissions on database gave myself permissions and now it works