...

View Full Version : Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING



hmvrulz
01-08-2007, 08:01 PM
i am a new to php... i am trying to code a web counter based on lzcounter..

i am getting this error...


Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/freehost/t35.com/h/m/hmv/install.php on line 39



here's code of the page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>:: hmvCounter v1.0 Installation ::</title>

</head>

<body>
<?php

if($_GET['s'] == "install") {
if(
(empty($_POST[hmv_mysqlserver])) OR
(empty($_POST[hmv_mysqluser])) OR
(empty($_POST[hmv_mysqlpass])) OR
(empty($_POST[hmv_mysqldbname])) OR
(empty($_POST[hmv_ipsperre])) OR
(empty($_POST[hmv_onlinetime])) OR
(empty($_POST[hmv_uonline])) OR
(empty($_POST[hmv_browos]))) die("You must fill ALL fields!!");

// create config.inc.php

$_hmvcreateconfig .= "<?php \n";
$_hmvcreateconfig .= " /************************************** \n";
$_hmvcreateconfig .= " * * \n";
$_hmvcreateconfig .= " * hmv-Counter v1.0 * \n";
$_hmvcreateconfig .= " * * \n";
$_hmvcreateconfig .= " * by Harsha M V * \n";
$_hmvcreateconfig .= " * http://hmv.in * \n";
$_hmvcreateconfig .= " * * \n";
$_hmvcreateconfig .= " **************************************/ \n";
$_hmvcreateconfig .= " \$_config = array(); \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " /************************************** \n";
$_hmvcreateconfig .= " * MySQL * \n";
$_hmvcreateconfig .= " **************************************/ \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " \$_config['sqlhost'] = ""; // host of the mysql database \n";
$_hmvcreateconfig .= " \$_config['sqluser'] = ""; // mysql username \n";
$_hmvcreateconfig .= " \$_config['sqlpass'] = ""; // mysql password \n";
$_hmvcreateconfig .= " \$_config['sqlname'] = ""; // mysql database \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " /************************************** \n";
$_hmvcreateconfig .= " * Settings * \n";
$_hmvcreateconfig .= " **************************************/ \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " \$_config['ipbarrier'] = ""; // Time in seconds of the IP barrier \n";
$_hmvcreateconfig .= " \$_config['ontime'] = ""; // Time in seconds where a users counts as online \n";
$_hmvcreateconfig .= " \$_config['onshow'] = ""; // Activate user online function? (ON/OFF) \n";
$_hmvcreateconfig .= " \$_config['browstats'] = ""; // Generate Browser Statitics ? (ON/OFF) \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " /************************************** \n";
$_hmvcreateconfig .= " * Error messages * \n";
$_hmvcreateconfig .= " **************************************/ \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " \$_config['sqlerror'] = "Database not Reachable"; // error message if the database is not reachable \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " /************************************** \n";
$_hmvcreateconfig .= " * DONT CHANGE BELOW * \n";
$_hmvcreateconfig .= " **************************************/ \n";
$_hmvcreateconfig .= " \n";
$_hmvcreateconfig .= " \$_config['userip'] = getenv(\"REMOTE_ADDR\"); \n";
$_hmvcreateconfig .= " \$_config['userhost'] = gethostbyaddr(getenv(\"REMOTE_ADDR\")); \n";
$_hmvcreateconfig .= " \$_config['useragent'] = getenv(\"HTTP_USER_AGENT\"); \n";
$_hmvcreateconfig .= " \$_config['time'] = time(); \n";
$_hmvcreateconfig .= " \$_config['thedate'] = date(\"Y-m-d\",time()); \n";
$_hmvcreateconfig .= "?> \n";

$hmv_openconfig = fopen("config.inc.php","w");
$hmv_writeconfig = fputs($hmv_openconfig,"$_hmvcreateconfig");
$hmv_closeconfig = fclose($hmv_openconfig);

$db = @mysql_connect($_POST['hmv_mysqlserver'],$_POST['hmv_mysqluser'],$_POST['hmv_mysqlpass'])or die(mysql_error());
$dbselect = @mysql_select_db($_POST['hmv_mysqldbname'])or die(mysql_error());

$date = date("Y-m-d",time());

mysql_query("CREATE TABLE hmvCounterData (
id int(4) NOT NULL auto_increment,
visitors int(10) NOT NULL default '0',
hits int(10) NOT NULL default '0',
today int(5) NOT NULL default '0',
yesterday int(5) NOT NULL default '0',
todate date NOT NULL default '0000-00-00',
useronline int(5) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM",$db);

mysql_query("CREATE TABLE hmvCounterIP (
id int(5) NOT NULL auto_increment,
ip varchar(41) NOT NULL default '',
timestamp int(100) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM",$db);

mysql_query("CREATE TABLE hmvCounterOnline (
ip char(60) NOT NULL default '0',
onlinetime int(200) NOT NULL default '0'
) TYPE=MyISAM",$db);

mysql_query("CREATE TABLE hmvCounterAgents (
id int(5) NOT NULL auto_increment,
agent text NOT NULL,
hits int(4) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM",$db);

mysql_query("CREATE TABLE hmvCounterBrowser (
id int(4) NOT NULL auto_increment,
type varchar(255) NOT NULL default '',
content varchar(255) NOT NULL default '',
hits int(5) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM",$db);


mysql_query("INSERT INTO hmvCounterData (id, visitors, hits, today, yesterday, todate) VALUES (1, 0, 0, 0, 0, '$date')",$db)or die($mdie);



echo "<br><br><br><br><center>Installation Finished</center>\n";
echo "<br><br><center>Installation Finished<br><br>Please Remove this file Now to use the Script!</center>\n";
} else {
if(!is_writable("config.inc.php")){
$hmverorr .= "<br>the file <b>config.inc.php</b> is not writeable.<br>";
$hmverorr .= "please chmod config.inc.php to 666!<br>";
$hmverorr .= "Note: You can only continue the installation process if you fixed this problem<br><br>";
$hmverorr_stat = true;
}
?>

<?php
if(isset($hmverorr)) { echo $hmverorr . "<br><br>"; }
?>

<form action="install.php?s=install" method="post">
<table border="0" cellspacing="0" cellpadding="0" width="750">
<tr>
<td width="300" valign="top">:: MySQL Database Set Up<br><br>
<table border="0" cellspacing="0" cellpadding="0" width="300">
<tr>
<td width="100" align="left">Server:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><input type="text" name="hmv_mysqlserver" value=""></td>
</tr>
<tr>
<td width="100" align="left">Username:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><input type="text" name="hmv_mysqluser" value=""></td>
</tr>
<tr>
<td width="100" align="left">Password:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><input type="password" name="hmv_mysqlpass" value=""></td>
</tr>
<tr>
<td width="100" align="left">Database/Datenbank:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><input type="text" name="hmv_mysqldbname" value=""></td>
</tr>
</table>
</td>
<td width="50">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

<td width="300" valign="top">:: Settings<br><br>
<table border="0" cellspacing="0" cellpadding="0" width="400">
<tr>
<td width="200" align="left">IP barrier:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><input type="text" name="hmv_ipsperre" value=""></td>
</tr>
<tr>
<td width="200" align="left">Onlinetime:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><input type="text" name="hmv_onlinetime" value=""></td>
</tr>
<tr>
<td width="200" align="left">Useronline System?:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><select name="hmv_uonline"><option selected value=""></option><option value="ON">ON</option><option value="OFF">OFF</option></select></td>
</tr>
<tr>
<td width="200" align="left">Browser/Os Stats?:</td>
<td width="5" align="center"><font color="#FF0000">!</font></td>
<td width="195" align="right"><select name="hmv_browos"><option selected value=""></option><option value="ON">ON</option><option value="OFF">OFF</option></select></td>
</tr>
</table>
</td>
</tr>
</table>

<br><br><br>
<input type="submit" name="Submit" value="Install" <? if(isset($hmverorr_stat)) echo "disabled"; ?> >


</form>

<?php } ?>
</body>
</html>

what do i need to do.......

i checked the line its pointing out but dont know wht to do

whizard
01-08-2007, 08:05 PM
Can you copy that line (line 39) here?


ok, I did it myself..

its this line:

$_hmvcreateconfig .= " \$_config['sqlhost'] = ""; // host of the mysql database \n";

You need to escape any double quotes you have inside other double quotes, so change line 39 to this:


$_hmvcreateconfig .= " \$_config['sqlhost'] = \"\"; // host of the mysql database \n";

oops, didn't see CFMaBiSmAd's post



WOrked for me... it'll give an error for the next line as well, and so on, just go through and escape all the double quotes inside other double quotes...

Dan

hmvrulz
01-08-2007, 08:16 PM
sorry... forgot to mention that...




39: $_hmvcreateconfig .= " \$_config['sqlhost'] = ""; // host of the mysql database \n";
40: $_hmvcreateconfig .= " \$_config['sqluser'] = ""; // mysql username \n";
41: $_hmvcreateconfig .= " \$_config['sqlpass'] = ""; // mysql password \n";
42: $_hmvcreateconfig .= " \$_config['sqlname'] = ""; // mysql database \n";
43: $_hmvcreateconfig .= " \n";

CFMaBiSmAd
01-08-2007, 08:19 PM
Actually, the color highlighting in the post points out a problem with un-escaped double-quotes within one of the strings Database not Reachable that is probably triggering the error.

hmvrulz
01-08-2007, 08:30 PM
Can you copy that line (line 39) here?


ok, I did it myself..

its this line:

$_hmvcreateconfig .= " \$_config['sqlhost'] = ""; // host of the mysql database \n";

You need to escape any double quotes you have inside other double quotes, so change line 39 to this:


$_hmvcreateconfig .= " \$_config['sqlhost'] = \"\"; // host of the mysql database \n";



WOrked for me... it'll give an error for the next line as well, and so on, just go through and escape all the double quotes inside other double quotes...

Dan

thank you every much sir... i got to know my mistake...

sir can u tell me why those slashes need to be put

whizard
01-08-2007, 08:41 PM
They tell PHP to ignore them and just write them to the screen, since they are characters which mean something special to PHP.

See here for more:
http://us3.php.net/manual/en/language.types.string.php

Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum