I’m working on a membership system. My only problem is i need it so you can only view the pages if your registered and logged in. Also i accidently deleted a section of my code and cant remember how to fix it. It collects all the data from the MySQL database. I know this probably seems really stupid, but my knowledge of PHP is poor. Thanks for the help…
the code your’e missing sounds like a mysql SELECT statement.
as far as setting a login, you basically need to use either php sessions or cookies. then you’ll basically have an if statement in your php to test whether the person is logged in based on the session or cookie.
I’ve done that but still nothing comes up, to link to data from the database i should be using <? echo $username ?> right?
ummm…no
then what do i use?
select
Your gonna want a book for this one.
ive done the select bit, i mean if i wanna display the username which i have selected from the database, i use <? echo $username ?>…?
$row = mysql_fetch_assoc($query);
$username = $row[‘username’];
echo $username;
[SIZE=1][U]I’m having this problem:
[/U][/SIZE] Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\sites\New Folder\includes\select.php on line **4
[SIZE=1][U]this is my code:
[/U][/SIZE]**[SIZE=1][SIZE=2]
// Get users information
$result = mysql_query("SELECT * FROM `test` WHERE `userid` = '".$u."' LIMIT 1");
while($r=mysql_fetch_array($result))
[/SIZE]
Can anyone help?
[/SIZE]
ok i sorted that problem out, but still it doesnt display my users info…
any ideas??
i’m using this to display my username for “userid 1”…
<? echo $r[username] ?>
it isnt working, any help?
Ah its alright, i sorted it. no doubt i’ll be back with more questions.
Thanks for the help…