Jump to content

unexpected T_VARIABLE


gaugeboson

Recommended Posts

<?php

 

require("config.php");

 

if(isset($_GET['id']) == TRUE) {

  if(is_numeric($_GET['id']) == FALSE) {

  $error = 1;

  }

 

  if($error == 1) {

  header("Location: " . $config_basedir);

  }

  else {

    $validentry = $_GET['id'];

    }

}

else {

  $validentry = 0;

}

if($_POST['submit']) {

  $db = mysql_connect($dbhost, $dbuser, $dbpassword);

  mysql_select_db($dbdatabase, $db);

 

  $sql = "INSERT INTO comments(blog_id, dateposted,

  name, comment) VALUES("

  $validentry . ", NOW(), '" . $_POST['name']

  . "', '" . $_POST['comment'] . "');";

  mysql_query($sql);

  header("Location: http://" . $HTTP_HOST

  . $SCRIPT_NAME . "?id=" . $validentry);

 

Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\viewentry.php on line 26

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

<?php

require("config.php");

if(isset($_GET['id']) == TRUE) {
  if(is_numeric($_GET['id']) == FALSE) {
  $error = 1;
  }

  if($error == 1) {
   header("Location: " . $config_basedir);
   }
   else {
     $validentry = $_GET['id'];
     }
}
else {
  $validentry = 0;
}
if($_POST['submit']) {
  $db = mysql_connect($dbhost, $dbuser, $dbpassword);
  mysql_select_db($dbdatabase, $db);

  $sql = "INSERT INTO comments(blog_id, dateposted,
  name, comment) VALUES(" .
  $validentry . ", NOW(), '" . $_POST['name']
  . "', '" . $_POST['comment'] . "');";
  mysql_query($sql);
  header("Location: http://" . $HTTP_HOST
  . $SCRIPT_NAME . "?id=" . $validentry);

 

you forgot the dot( . )

Link to comment
https://forums.phpfreaks.com/topic/93888-unexpected-t_variable/#findComment-481059
Share on other sites

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.