Jump to content

[SOLVED] parse error?


spode

Recommended Posts

I'm getting this error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in crud.php on line 13

 

Heres the script (i'm only working on the first case...thats why it's incomplete)

 

<?php

$host = "********";
$username = "********";
$password = "*********";

$dbc = mysql_connect($host, $username, $password) or die (mysql_error());
$select = mysql_select_db('colsim0_mysql');

switch($action) {
case "edit":
	if (isset($_POST['submit'])) {
		$insertinfo = "UPDATE tbl_users SET username=$_POST['uname'],password=$_POST['npass'] WHERE uid=$uid";
		if (mysql_query($insertinfo)) {
			echo "Information successfully updated!";
			} else {
			echo "Information failed to update because " . mysql_error();
			}
		} else {
		echo "<h1>Edit Information</h1>
		<form action=\"crud.php\" method=\"post\">
		<table>
			<tr>
				<td>Username:</td>
				<td><input type=\"text\" name=\"uname\" size=\"20\"></td>
			</tr>
			<tr>
				<td>Current Password:</td>
				<td><input type=\"text\" name=\"cpass\" size=\"20\"></td>
			</tr>
			<tr>
				<td>New Password:</td>
				<td><input type=\"text\" name=\"npass\" size=\"20\"></td>
			</tr>
			<tr>
				<td><input type=\"submit\" name=\"submit\" value=\"Update\">
				</form>
		</table>";
		}
	break;
}
//case "delete":

?>

 

Thanks for the help. If I need to include the file that comes before this...just let me know.

Link to comment
Share on other sites

<?php

$insertinfo = "UPDATE tbl_users SET username=$_POST['uname'],password=$_POST['npass'] WHERE uid=$uid";

?>

 

<?php

  $username = $_POST['uname'];
  $password = $_POST['npass'];

  $insertinfo = "UPDATE tbl_users SET username='$username',password='$password' WHERE uid='$uid'";

?>

Link to comment
Share on other sites

<?php

$host = "********";
$username = "********";
$password = "*********";

$dbc = mysql_connect($host, $username, $password) or die (mysql_error());
$select = mysql_select_db('colsim0_mysql');

switch($action) {
case "edit":
	if (isset($_POST['submit'])) {
		$insertinfo = "UPDATE tbl_users SET username=" . $_POST['uname'] . ",password=" . $_POST['npass'] . " WHERE uid=$uid";
		if (mysql_query($insertinfo)) {
			echo "Information successfully updated!";
			} else {
			echo "Information failed to update because " . mysql_error();
			}
		} else {
		echo "<h1>Edit Information</h1>
		<form action=\"crud.php\" method=\"post\">
		<table>
			<tr>
				<td>Username:</td>
				<td><input type=\"text\" name=\"uname\" size=\"20\"></td>
			</tr>
			<tr>
				<td>Current Password:</td>
				<td><input type=\"text\" name=\"cpass\" size=\"20\"></td>
			</tr>
			<tr>
				<td>New Password:</td>
				<td><input type=\"text\" name=\"npass\" size=\"20\"></td>
			</tr>
			<tr>
				<td><input type=\"submit\" name=\"submit\" value=\"Update\">
				</form>
		</table>";
		}
	break;
}
//case "delete":

?>

 

Array values, when referring to them you need to concat them. The above should work now.

Link to comment
Share on other sites

Ok the 'Action not found' came up after I hit submit this time...Here's the file that you visit first:

 

<?php


$dbc = mysql_connect($host, $username, $password) or die (mysql_error());
$dbselect = mysql_select_db('colsim0_mysql') or die (mysql_error());

$retrieve = 'SELECT uid, username, password FROM tbl_users';
$result = mysql_query($retrieve);

while($list = mysql_fetch_array($result)) {
echo "<p><a href=\"crud.php?uid={$list['uid']}&action=edit\">Edit Password</a>
	<a href=\"crud.php?uid={$list['uid']}&action=delete\">Delete</a>
	{$list['username']}</p>";
}
echo '<br /><br />';
echo "<p>Don't have an account? Register by clicking <a href=\"crud.php?action=new\">here</a></p>";

mysql_close();

?>

 

And here's the one after it (the one we've been looking at.)

 

<?php



$dbc = mysql_connect($host, $username, $password) or die (mysql_error());
$select = mysql_select_db('colsim0_mysql');

switch($action) {
case "edit":
	if (isset($_POST['submit'])) {
		$insertinfo = "UPDATE tbl_users SET username=" . $_POST['uname'] . ",password=" . $_POST['npass'] . " WHERE uid=$uid";
		if (mysql_query($insertinfo)) {
			echo "Information successfully updated!";
			} else {
			echo "Information failed to update because " . mysql_error();
			}
		} else {
		echo "<h1>Edit Information</h1>
		<form action=\"crud.php\" method=\"post\">
		<table>
			<tr>
				<td>Username:</td>
				<td><input type=\"text\" name=\"uname\" size=\"20\"></td>
			</tr>
			<tr>
				<td>Current Password:</td>
				<td><input type=\"text\" name=\"cpass\" size=\"20\"></td>
			</tr>
			<tr>
				<td>New Password:</td>
				<td><input type=\"text\" name=\"npass\" size=\"20\"></td>
			</tr>
			<tr>
				<td><input type=\"submit\" name=\"submit\" value=\"Update\">
				</form>
		</table>";
		}
	break;
default:
	echo "Action not found.";
	break;
}	
?>

 

hmmm

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.