Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    137
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

    i am a new to php... i am trying to code a web counter based on lzcounter..

    i am getting this error...
    PHP Code:
    Parse errorsyntax errorunexpected T_CONSTANT_ENCAPSED_STRING in /home/freehost/t35.com/h/m/hmv/install.php on line 39 

    here's code of the page
    PHP Code:
    <!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

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Can you copy that line (line 39) here?

    Edit:
    ok, I did it myself..

    its this line:
    PHP Code:
    $_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:

    PHP Code:
    $_hmvcreateconfig    .=    " \$_config['sqlhost'] = \"\"; // host of the mysql database \n"
    Edit: 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
    Last edited by whizard; 01-08-2007 at 08:31 PM.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    Regular Coder
    Join Date
    Jan 2007
    Posts
    137
    Thanks
    5
    Thanked 0 Times in 0 Posts
    sorry... forgot to mention that...


    PHP Code:
    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"

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,065
    Thanks
    2
    Thanked 317 Times in 309 Posts
    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.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    Regular Coder
    Join Date
    Jan 2007
    Posts
    137
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by whizard View Post
    Can you copy that line (line 39) here?

    Edit:
    ok, I did it myself..

    its this line:
    PHP Code:
    $_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:

    PHP Code:
    $_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

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    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
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •