/    Sign up×
Community /Pin to ProfileBookmark

can’t get loginscript working

[code]
<?
$db = mysql_connect(‘db1.awardspace.com’,’renevanh_djoi’,’secret’)
or die (‘kan geen verbinding maken’ . mysql_error());

mysql_select_db(‘renevanh_djoi’,$db);

$username = $_POST[“ussr”];
$password = $_POST[“psswrd”];

$sql= “SELECT ussr, psswrd
FROM vrijwilligers
WHERE ussr = $username;

$result = mysql_query($sql);
$temp = mysql_fetch_array($result);
$password2 = $temp[‘psswrd’];
if ($password != $password2) {
echo “werkt niet”;
}
else {
echo “doet het :D”;
}

msyql_close($db);

?>
[/code]

This is the latest thing I tried while trying to get a login script working, but I get an error and I don’t know what to change.
The error:

[code]
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/djoi.awardspace.com/Scripts/login.php on line 16
[/code]

Line 16 is the $password2 = $temp[‘psswrd’]; line. What’s wrong with it or the one above?
Why isn’t my script working?

René
php noob :p

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@MatMelNov 22.2006 — There is an " missing in this statement:

[code=php]$sql= "SELECT ussr, psswrd
FROM vrijwilligers
WHERE ussr = $username"; <=this one[/code]
Copy linkTweet thisAlerts:
@renevanhauthorNov 22.2006 — Thanks, that made the error go away.

I thought it would work now, but the next errors jumps in:

<i>
</i>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/djoi.awardspace.com/Scripts/login.php on line 15


The code:

<i>
</i>&lt;?
$db = mysql_connect('db1.awardspace.com','renevanh_djoi','secret')
or die ('kan geen verbinding maken' . mysql_error());

mysql_select_db('renevanh_djoi',$db);

$username = $_POST["ussr"];
$password = $_POST["psswrd"];

$sql= "SELECT ussr, psswrd
FROM vrijwilligers
WHERE ussr = $username";

$result = mysql_query($sql);
$temp = mysql_fetch_array($result);
$password2 = $temp['psswrd'];
if ($password != $password2) {
echo "werkt niet";
}
else {
echo "doet het :D";
}

mysql_close($db);

?&gt;


René
Copy linkTweet thisAlerts:
@MatMelNov 22.2006 — Well I didn't recognize it before:

you have to put ' around non-integer values in mysql querys:
[code=php]
$sql= "SELECT ussr, psswrd
FROM vrijwilligers
WHERE ussr = '$username' <- this ones";[/code]
Copy linkTweet thisAlerts:
@renevanhauthorNov 22.2006 — ? ?

Working correctly now ?

Learned something really usefull: the quotation marks around non integers in queries.

Thanks!

René
×

Success!

Help @renevanh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...