asucrews Posted August 26, 2008 Share Posted August 26, 2008 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!!! Link to comment https://forums.phpfreaks.com/topic/121373-parse-error-syntax-error-unexpected-t_if-in-line-26/ Share on other sites More sharing options...
haku Posted August 26, 2008 Share Posted August 26, 2008 $sql = "CREATE TABLE $tablename (id int(4) NOT NULL AUTO_INCREMENT,PRIMARY KEY(personID), linkaddress varchar(50),linkname varchar(50))" You forgot something there. Link to comment https://forums.phpfreaks.com/topic/121373-parse-error-syntax-error-unexpected-t_if-in-line-26/#findComment-625793 Share on other sites More sharing options...
JasonLewis Posted August 26, 2008 Share Posted August 26, 2008 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 ) Take a look at the $sql variable line.. What's missing at the end? Link to comment https://forums.phpfreaks.com/topic/121373-parse-error-syntax-error-unexpected-t_if-in-line-26/#findComment-625795 Share on other sites More sharing options...
asucrews Posted August 26, 2008 Author Share Posted August 26, 2008 thanks!!!! i was missing alot of them i moveing on to my new error :T but i hack at it and see what i can do Link to comment https://forums.phpfreaks.com/topic/121373-parse-error-syntax-error-unexpected-t_if-in-line-26/#findComment-625800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.