Jump to content

BlackStones

New Members
  • Posts

    4
  • Joined

  • Last visited

BlackStones's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the replies, I've been a bit busy but now I have time to allocate to educating myself. @bsmither I'm trying to resolve this error, I was following a video tutorial online. @Jacques1 I'm so uneducated, I'm learning on W3 schools. Do you have any additional resources I can use to help myself?
  2. Fatal error: Can't use function return value in write context on line 21 Hello, I am creating a login_parse php file that will facilitate user authentication on a website. I have received the above error with the code below. The line that yields the error is $_SESSION('uid') = $row['id']; As always, I am grateful for the assistance. <?php session_start(); include_once("connect.php"); if (!isset($_POST['username'])) { $username = $_POST['username']; $password = $_POST['password']; $sql = "SELECT * FROM users WHERE username='".$username."' AND password ='".$password."' LIMIT 1"; $res = mysql_query($sql) or die(mysql_error()); $ifstmt = mysql_num_rows(mysql_query($res)); if($ifstmt == 1) { $row = mysql_fetch_assoc($res); $_SESSION('uid') = $row['id']; $_SESSION('username') = $row['username']; header("Location: demo.php"); exit(); } else { echo "Invalid login information. Please return to the previous page"; exit(); } } ?>
  3. Here is the error code I am receiving; Parse error: syntax error, unexpected $end (line 41) The error message has consistently identified the statement in the else clause. Thanks for any help. <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Blah</title> <link rel="stylesheet" type="text/css" href="defaultcss.css" /> </head> <body> <div id ="wrapper"> <h2>Blah Forum Demo</h2> <p>Creating basic login functionality</p> <?php if (!isset($_SESSION['uid'])) { echo "<form action = 'login_parse.php' method ='post'> Username: <input type ='text' name='username' /> Password: <input type ='password' name='password' /> Submit: <input type ='submit' name='submit' value='Log In' /> "; } else { echo "<p>You are logged in as ".$_SESSION['username']." • <a href='logout_parse.php'>Logout</a>; } ?> </div> </body> </html>
×
×
  • 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.