subman Posted March 29, 2008 Share Posted March 29, 2008 Hi, im creating a user script, and im having trouble populating a field with php. Heres my structure! <?php //Admin Functions include("config.php"); /** * Displays the user and allows you to edit them */ function editUser($user) { $sql = "SELECT * FROM `users` WHERE `username` = '$user'"; $query = mysql_query($sql) or die(mysql_error()); while ($fetch = mysql_fetch_array($query)) { $form = '<form name="Edit" method="POST" action="'.$_SERVER['PHP_SELF'].'">'; $form .= '<h3><b>Edit User -</b></h3><br />'; $form .= 'Username: <input type="text" name="user" value="$fetch['username']"/><br />'; $form .= 'Password: <input type="password" name="pass" value="$fetch['password']"/><br />'; $form .= 'Email: <input type="text" name="email" value="$fetch['email']"/><br />'; $form .= '<input type="submit" name="user" value="Submit"/>'; $form .= '</form>'; echo $form; } } function selectUser() { $form = '<form name="Edit" method="POST" action="'.$_SERVER['PHP_SELF'].'">'; $form .= '<h3><b>Edit User -</b></h3><br />'; $form .= 'Username: <input type="text" name="user" value=""/><br />'; $form .= '<input type="submit" name="edit" value="Submit"/>'; $form .= '</form>'; } function deleteUser() { } function siteConfig() { } ?> Parse error: syntax error, unexpected T_STRING in C:\wamp\www\php\users\adminfunctions.php on line 16 Thats what i keep getting and im not quite sure how to fix it, it has something todo with the value field in the form.. but i dont know what else to do. Link to comment https://forums.phpfreaks.com/topic/98474-html-value-and-php/ Share on other sites More sharing options...
wildteen88 Posted March 29, 2008 Share Posted March 29, 2008 You cannot use variables within single quotes,: $form .= 'Username: <input type="text" name="user" value="$fetch['username']"/><br />'; $form .= 'Password: <input type="password" name="pass" value="$fetch['password']"/><br />'; $form .= 'Email: <input type="text" name="email" value="$fetch['email']"/><br />'; You should do: $form .= 'Username: <input type="text" name="user" value="'.$fetch['username'].'"/><br />'; $form .= 'Password: <input type="password" name="pass" value="'.$fetch['password'].'"/><br />'; $form .= 'Email: <input type="text" name="email" value="'.$fetch['email'].'"/><br />'; Link to comment https://forums.phpfreaks.com/topic/98474-html-value-and-php/#findComment-503946 Share on other sites More sharing options...
subman Posted March 29, 2008 Author Share Posted March 29, 2008 Thanks! I didnt think about that! Link to comment https://forums.phpfreaks.com/topic/98474-html-value-and-php/#findComment-503948 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.