Jump to content

Unexpected T_VARIABLE


TwoArmadillos

Recommended Posts

Hi,

 

I've Googled this error code, but all the problems I can find seem to be caused by missing semi-colons. I don't think that's what's causing mine though.

 

<?php
include 'p7av685m/mysqlcon.php';

$guid = $_GET['GUID'];

$sql = mysql_query("SELECT * FROM `users` WHERE `guid`='{$guid}'") or die (mysql_error());
//$result = mysql_fetch_array($sql);
//echo $result['guid'];
//echo mysql_num_rows($sql);

if(mysql_num_rows($sql) == '1'){
  $query = mysql_query("UPDATE `users` SET `is_active`='1' WHERE `guid`='".$guid."'") or die (mysql_error());
  echo "Registration process complete. You are now activated.";
} else { echo "User not found"; }

include 'p7av685m/closecon.php';
?>

 

I can successfully run the actual query on phpmyadmin. But on the server it gives me this:

Parse error: syntax error, unexpected T_VARIABLE on line 12. The currently commented out echos print successfully as well.

Link to comment
https://forums.phpfreaks.com/topic/143801-unexpected-t_variable/
Share on other sites


if(mysql_num_rows($sql) == '1'){
  $query = mysql_query("UPDATE `users` SET `is_active`='1' WHERE `guid`='".$guid."'") or die (mysql_error());
  echo "Registration process complete. You are now activated.";
} else { echo "User not found"; }

 

change this to

 

<?php

if(mysql_num_rows($sql) == '1'){
  $query = mysql_query("UPDATE `users` SET `is_active`='1' WHERE `guid`='$guid'  ") or die (mysql_error());
  echo "Registration process complete. You are now activated.";
} else { echo "User not found"; }

?>

yeah what you did wrong was not closing the " for the mysql query...

 

 

  $query = mysql_query("UPDATE `users` SET `is_active`='1' WHERE `guid`='".$guid."'" ) or die (mysql_error());

 

there is no closing tag for the sql query.

 

There seems to be?

$query = mysql_query("UPDATE `users` SET `is_active`='1' WHERE `guid`='".$guid."'" ) or die (mysql_error());

There seems to be?

$query = mysql_query("UPDATE `users` SET `is_active`='1' WHERE `guid`='".$guid."'" ) or die (mysql_error());

 

 

no because that is closing the ' before it

 

$query = mysql_query("UPDATE `users` SET `is_active`='1' WHERE `guid`='".$guid."'" ) or die (mysql_error());

 

becasue the red " is closing for the blue " you see?

 

 

Archived

This topic is now archived and is closed to further replies.

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