Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum > PHP Code Library
User Name
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Thread Tools Search this Thread Rate Thread
Old 18-Nov-2006, 20:49
Richardknox Richardknox is offline
Awaiting Email Confirmation
Join Date: Nov 2006
Location: Michigan
Posts: 88
Richardknox is on a distinguished road

Parse error: parse error, unexpected T_STRING


I am slowly learning to use PHP for the website that I am putting together. So, please understand that I am a newbee to PHP, and MySql.

I am also creating this script from other bits and pieces from other scripts, so that might be part of my problem.

What I am attempting to accomplish here, is to update a variable by adding one to it, and then sending it back to the database to be updated there, before going to the website that the user selected.

This is the error that I am getting...

Parse error: parse error, unexpected T_STRING in /home/content/R/i/c/RichardAKnox/html/ace.php on line 43

This is my script:

PHP Code:

//Connect To Database

$dblink = mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");

mysql_select_db($dbname, $dblink);


$query = "SELECT * FROM wcdatabase WHERE id = ($id) LIMIT 0, 30 ";

$result = mysql_query($query,$dblink);

$row = mysql_fetch_assoc($result);

$viewed = $row["viewed"];
$viewed = $row["viewed"];

Line 43 error ---->>>  $query = UPDATE wcdatabase SET viewed = $viewed;

// Redirect to the link URL

Header("Location: $link");


I used to have a few echo statements in this script to verify that certain aspects of the script worked. But, as soon as I added the Line 43 portion, then the script stopped working, and gave me the errors listed.

Thanks for any help,

Last edited by LuciWiz : 19-Nov-2006 at 09:44. Reason: Please insert your Php code between [php] & [/php] tags
Old 21-Dec-2006, 11:15
TreyAU21's Avatar
TreyAU21 TreyAU21 is offline
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 116
TreyAU21 has a spectacular aura aboutTreyAU21 has a spectacular aura about

Re: Parse error: parse error, unexpected T_STRING

The query that you want to run should be stored as a string...

PHP Code:

// Yours
$query = UPDATE wcdatabase SET viewed = $viewed;

//CORRECT WAY(S)... Notice the quotations.
$query = "UPDATE wcdatabase SET viewed = $viewed";
// OR
$query = "UPDATE wcdatabase SET viewed = " . $viewed; 

Look at how you have the SELECT query above in quotations... you need the same thing for the update query... including actually calling the mysql_query() function call to actually query the db.
If practice makes perfect and nobody's perfect... why practice?

Web Design Company:
Old 19-May-2007, 12:27
Curtiss Curtiss is offline
New Member
Join Date: May 2007
Posts: 1
Curtiss is on a distinguished road

Re: Parse error: parse error, unexpected T_STRING

Im getting an error like that also, and can not figure out why i am also new to PHP and Mysql. The line that i am having the error on is the one that says VALUES ('".$_POST['username']."', '".$_POST['password']."')";
thanks for any help

PHP Code:



// Connects to your Database 
mysql_connect("host", "user", "pass") or die(mysql_error()); 
mysql_select_db("EGAlive") or die(mysql_error()); 

//This code runs if the form has been submitted
if (isset($_POST['submit'])) { 

//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('You did not complete all of the required fields');

// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") 
or die(mysql_error());
$check2 = mysql_num_rows($check);

//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');

// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('Your passwords did not match. ');

// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);

// now we insert it into the database $insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['username']."', '".$_POST['password']."')";[/color]
$add_member = mysql_query($insert);

<!-- Now we let them know if their registration was successful -->
<p>Thank you, you have registered - you may now login</a>.</p>

<!-- This is what they see before they have registered -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<input type="text" name="username" maxlength="60">
<input type="password" name="pass" maxlength="10">
<tr><td>Confirm Password:</td><td>
<input type="password" name="pass2" maxlength="10">
<tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table>



Old 19-May-2007, 14:42
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,519
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error: parse error, unexpected T_STRING

Bring the assignment to $insert to the next line.

If you look back at the formatted code in your post, you should see the problem, it looks like it is part of the comment.
Use the the source!!
WYCIWYG -- what you code is what you get!

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apologies In Advance Parse error: parse error, unexpected T_STRING, expecting T_VARI sph2005 MySQL / PHP Forum 11 17-Jul-2006 09:28
Parse Error vigilantweather MySQL / PHP Forum 3 21-Feb-2006 13:24
Parse Error vigilantweather MySQL / PHP Forum 6 04-Feb-2006 14:15

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:40.

vBulletin, Copyright © 2000 - 2018, Jelsoft Enterprises Ltd.