1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Parse error: syntax error, unexpected T_DNUMBER (PLZZ HELP)

Discussion in 'PHP' started by IshanFdo, Jul 6, 2012.

  1. #1
    The Error is
    [B]Parse error: syntax error, unexpected T_DNUMBER in [B]/home/a9720714/public_html/lib/lib.php on line [B]48[/B][/B][/B]
    Code (markup):
    Lib.php Is
    <?php
    /* security*/  $xHost = $_SERVER['SERVER_NAME'];
      $xReferer = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
      //$xContents = @file_get_contents("http://ptcpay.com/license.php?id=5&domain=$xHost&referer=".urldecode($xReferer));    if(!empty($xContents)) die($xContents);    //lib startsession_start();
    if(!defined('DB_DETAILS')) {include_once($prefix_s.'lib/lib_database.php');}
    if(!function_exists("set_error")) {include_once($prefix_s.'lib/lib_functions.php');}
    if(mysql_ver() < 5){set_error("Your server doesn't support MySQL 5, Please install MySQL 5 to have Gen2 perform at it's best.");}
    if(PHP_VERSION < 5.1){set_error("Your server's PHP version is incompatible with Gen2. Gen2 is only compatible with PHP Version 5.1.0 and above.");}
    if(!defined('load_gen2')){set_error("We could not load the agent because a request was not declared properly.");$err_l = true;}
    if(!$c = mysql_connect(DB_HOST, DB_USER, DB_PASS)){set_error("We couldn't establish a connection to your MySQL server.");$err_l = true;}if(!mysql_select_db(DB_NAME, $c)){set_error("We couldn't establish a connection to your MySQL database.");$err_l = true;}
    
    if(!$error_load){DEFINE('START_PROCESS', true);}
    $do->refresh_sess();?>
    PHP:
    And line 48 is
    if(!$c = mysql_connect(DB_HOST, DB_USER, DB_PASS)){set_error("We couldn't establish a connection to your MySQL server.");$err_l = true;}if(!mysql_select_db(DB_NAME, $c)){set_error("We couldn't establish a connection to your MySQL database.");$err_l = true;}
    PHP:
    If someone could slove this problem.I will Pay you 3$ Via paypal.
     
    Solved! View solution.
    IshanFdo, Jul 6, 2012 IP
  2. krishmk

    krishmk Well-Known Member

    Messages:
    1,376
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    #2
    I believe the culprit here is the value of DB_HOST. If the hostname is an IP address make sure you define it using double quotes instead of single quotes.
    If you have a period mark (dot) in DB_USER or DB_PASS you will have to wrap them using double quotes.
    Hope that helps!
     
    krishmk, Jul 6, 2012 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #3
    NOT that you should be storing the mysql information in DEFINE where any script that can get itself running regardless of privileges can suddenly have access to it. Scripting language 101, passwords/login info + DEFINE == security hole big enough to sail the USS IOWA through...

    No matter what the ignorant fools behind wordpress think.

    Though @krishmk, singles or doubles shouldn't matter on a STRING value -- both make strings, even on define. I'd suspect no quotes are being used. Singles in fact should be preferred, since they have less parsing overhead.
     
    deathshadow, Jul 6, 2012 IP
  4. IshanFdo

    IshanFdo Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    I dont know php so can u correct it and post the line 48 as a PHP
     
    IshanFdo, Jul 6, 2012 IP
  5. IshanFdo

    IshanFdo Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    Plz Help someone help
     
    IshanFdo, Jul 8, 2012 IP
  6. KristianI

    KristianI Greenhorn

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    8
    #6
    Find the line where you have this:

    DEFINE('DB_HOST', ....);

    and change it to
    DEFINE("DB_HOST", "127.0.0.1");
    of course the IP address should be the one your mysql is on.
     
    KristianI, Jul 9, 2012 IP
  7. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #7
    Why add overhead when there's no variable to parse?

    Aside from the security hole,

    DEFINE('DB_HOST', '127.0.0.1');

    is the same thing, but it parses faster.
     
    Rukbat, Jul 13, 2012 IP
  8. KristianI

    KristianI Greenhorn

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    8
    #8
    Ok, there is a security risk, but how you define the DB connection values then?
     
    KristianI, Jul 14, 2012 IP
  9. #9
    You can define DB values as follow

    $DB_HOST = "localhost";
    $DB_USER = "root";
    $DB_PASS = "test";
    $DB_NAME = "anydb";

    then u can use them as

    if(!$c = mysql_connect($DB_HOST, $DB_USER, $DB_PASS)){set_error("We couldn't establish a connection to your MySQL server.");$err_l = true;}if(!mysql_select_db($DB_NAME, $c)){set_error("We couldn't establish a connection to your MySQL database.");$err_l = true;}

    I can help but i need full source code in include file specially error thing and DB inclusion file

    Regards,

    D NAjmi
     
    superlinksworld, Jul 14, 2012 IP
  10. jimmyb29

    jimmyb29 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #10
    Hi,

    I think I'm having a similar problem with a DB, which won't connect. This is "store bought code, and I'm a newbie, so I'm lost. I get the 111 error code, no connection. Any help much appreciated.
    Here's the code:

    <?php
    // CONNECT TO THE SERVER AND SELECT DATABASE
    $server = "jimmybryantnet.ipagemysql.com";
    $user = "jimmybryantnet";
    $password = "******";
    $dataBase = "guestbook";

    $conx = mysql_connect($server,$user,$password);
    $db_selected = mysql_select_db($dataBase,$conx);

    if($conx && $db_selected){
    // IF CONNECTION IS ESTABLISHED
    $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
    $xml .= "<data>\n";

    if(isset($_POST['name'])){
    $result = 0;
    $name=mysql_escape_string(trim($_POST['name']));
    $email=mysql_escape_string(trim($_POST['email']));
    $message=mysql_escape_string(trim($_POST['message']));

    // ADD DATA TO THE TABLE guestbook WHEN THE USER PRESS THE send_btn in FLASH
    $sql="INSERT INTO guestbook(name,email,message,dateAdded)values('$name','$email','$message',now())";
    $query = mysql_query($sql,$conx);
    if ($query){
    $result= 1;
    $sql2 = "SELECT * FROM guestbook ORDER BY id DESC";
    $query2 = mysql_query($sql2,$conx);
    //WHEN query == true , GET LIST OF MESSAGES AND PUT THEM AS XML FILE
    while($data = mysql_fetch_array($query2)){
    $xml .= "<guest>\n";
    $xml .= "<name>".$data['name']."</name>\n";
    $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n";
    $xml .= "<sdate>".$data['dateAdded']."</sdate>\n";
    $xml .= "</guest>\n";
    }
    }
    else{
    $result=0;
    }
    $xml .= "<inserted>".$result."</inserted>\n";

    }
    if(isset($_POST['getMessage'])){
    // GET LIST OF MESSAGES AND PUT THEM AS XML FILE
    $sql = "SELECT * FROM guestbook ORDER BY id DESC";
    $query = mysql_query($sql,$conx);
    while($data = mysql_fetch_array($query)){
    $xml .= "<guest>\n";
    $xml .= "<name>".$data['name']."</name>\n";
    $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n";
    $xml .= "<sdate>".$data['dateAdded']."</sdate>\n";
    $xml .= "</guest>\n";
    }
    }
    $xml .= "</data>\n";
    echo $xml;
    }
    else{
    // IF CONNECTION == false OR DATABASE DOESN'T EXISTE
    die (mysql_error());
    }
    ?>
     
    jimmyb29, Apr 9, 2014 IP