Jump to content

Parse error: syntax error, unexpected T_IF in line 26


asucrews

Recommended Posts

i been looking at the section code for about hour....and i can't find were my error is...anyone have anyideas?

 

<?
include "config2.php";

function table_exists($tablename, $database = false) {

    if(!$database) {
        $res = mysql_query("SELECT DATABASE()");
        $database = mysql_result($res, 0);
    }

    $res = mysql_query("
        SELECT COUNT(*) AS count 
        FROM information_schema.tables 
        WHERE table_schema = '$database' 
        AND table_name = '$tablename'
    ");

    return mysql_result($res, 0) == 1;

}

$tablename2 = "linkonp1";
if(!table_exists($tablename2)){
$sql = "CREATE TABLE $tablename (id int(4) NOT NULL AUTO_INCREMENT,PRIMARY KEY(personID), linkaddress varchar(50),linkname varchar(50))";

        if (!mysql_query($sql,$conn)) {
		die('Error: ' . mysql_error());}

echo "Table Created! </br>";

$sql = "INSERT INTO $tablename ('id','linkaddress','linkname') VALUES ('','$linkname','$linkaddress')";

        if (!mysql_query($sql,$conn)) {
		die('Error: ' . mysql_error());}

echo "Data added to Table! </br>";

}else{
$sql = "INSERT INTO $tablename ('id','linkaddress','linkname') VALUES ('','$linkname','$linkaddress')";
if (!mysql_query($sql,$conn)) {
		die('Error: ' . mysql_error());
echo "Data added to Table! </br>"
}

?>

Link to page: http://ntinternationalinsurance.com/newassite/debug.php

Thanks for the help!!!

Line 26 it says... Most errors though, if you can't find anything on that line look above it. Also, change it from short-tags to proper and you should see the highlighting.

 

<?php
include "config2.php";

function table_exists($tablename, $database = false) {

   if(!$database) {
       $res = mysql_query("SELECT DATABASE()");
       $database = mysql_result($res, 0);
   }

   $res = mysql_query("
       SELECT COUNT(*) AS count 
       FROM information_schema.tables 
       WHERE table_schema = '$database' 
       AND table_name = '$tablename'
   ");

   return mysql_result($res, 0) == 1;

}

$tablename2 = "linkonp1";
if(!table_exists($tablename2)){
$sql = "CREATE TABLE $tablename (id int(4) NOT NULL AUTO_INCREMENT,PRIMARY KEY(personID), linkaddress varchar(50),linkname varchar(50))"

       if (!mysql_query($sql,$conn)) {
		die('Error: ' . mysql_error());}

echo "Table Created! </br>";

$sql = "INSERT INTO $tablename ('id','linkaddress','linkname') VALUES ('','$linkname','$linkaddress')"

       if (!mysql_query($sql,$conn)) {
		die('Error: ' . mysql_error());}

echo "Data added to Table! </br>";

}else{
$sql = "INSERT INTO $tablename ('id','linkaddress','linkname') VALUES ('','$linkname','$linkaddress')"
if (!mysql_query($sql,$conn)) {
		die('Error: ' . mysql_error());
echo "Data added to Table! </br>"
}

?>

(Syntax highlighting didn't do much in this instance :P)

 

Take a look at the $sql variable line.. What's missing at the end?

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.