Jump to content

Recommended Posts

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in

C:\www\myserver.dev\public_html\...........\install\install.php on line 49

 

can anyone help figure out what is wrong with that coding

 

46  if ($fp)

47   {

48 $content = "<?php \n"

49 " \n"

50 "/* Database Host Name */ \n".

51 "\$db_host = '" . $post_details['db_host'] . "'; \n".

52 " \n".

53 "/* Database Username */ \n".

54 "\$db_username = '" . $post_details['db_username'] . "'; \n".

55 " \n".

56 "/* Database Login Password */ \n".

57 "\$db_password = '" . $post_details['db_password'] . "'; \n".

58 " \n".

59 "/* Database and Session prefixes */ \n".

60 "define('DB_PREFIX', '" . $post_details['table_prefix'] . "'); ## Do not edit ! \n".

61 "define('SESSION_PREFIX', 'probid_'); \n".

62 " \n".

63 "/* Database Name */ \n".

64 "\$db_name = '" . $post_details['db_name'] . "'; \n".

65 "?>";

66

67 fputs($fp, $content);

68 fclose($fp);

Link to comment
https://forums.phpfreaks.com/topic/193811-parse-error-message/
Share on other sites

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in

C:\www\myserver.dev\public_html\...........\install\install.php on line 49

 

can anyone help figure out what is wrong with that coding

 

46  if ($fp)

47   {

48 $content = "<?php \n"

49 " \n"

50 "/* Database Host Name */ \n".

51 "\$db_host = '" . $post_details['db_host'] . "'; \n".

52 " \n".

53 "/* Database Username */ \n".

54 "\$db_username = '" . $post_details['db_username'] . "'; \n".

55 " \n".

56 "/* Database Login Password */ \n".

57 "\$db_password = '" . $post_details['db_password'] . "'; \n".

58 " \n".

59 "/* Database and Session prefixes */ \n".

60 "define('DB_PREFIX', '" . $post_details['table_prefix'] . "'); ## Do not edit ! \n".

61 "define('SESSION_PREFIX', 'probid_'); \n".

62 " \n".

63 "/* Database Name */ \n".

64 "\$db_name = '" . $post_details['db_name'] . "'; \n".

65 "?>";

66

67 fputs($fp, $content);

68 fclose($fp);

 

You need to add a concatenation operator, in other words a period, after your "\n"

Link to comment
https://forums.phpfreaks.com/topic/193811-parse-error-message/#findComment-1020062
Share on other sites

thank you for your response, i did add the period but still no luck and reporting the same parse error on line 49

 

46  if ($fp)

47    {

48      $content = "<?php \n"

49        " \n".

50        "/* Database Host Name */ \n".

51        "\$db_host = '" . $post_details['db_host'] . "'; \n".

52        " \n".

53        "/* Database Username */ \n".

54        "\$db_username = '" . $post_details['db_username'] . "'; \n".

55        " \n".

56        "/* Database Login Password */ \n".

57        "\$db_password = '" . $post_details['db_password'] . "'; \n".

58        " \n".

59        "/* Database and Session prefixes */ \n".

60        "define('DB_PREFIX', '" . $post_details['table_prefix'] . "'); ## Do not edit ! \n".

61        "define('SESSION_PREFIX', 'probid_'); \n".

62        " \n".

63        "/* Database Name */ \n".

64        "\$db_name = '" . $post_details['db_name'] . "'; \n".

65        "?>";

66

67      fputs($fp, $content);

68      fclose($fp);

Link to comment
https://forums.phpfreaks.com/topic/193811-parse-error-message/#findComment-1020411
Share on other sites

i did add one period after the ( $content = "<?php \n" )  but still giving the same error. strange though that it would not pick-up on that one since it's on line 48 and reporting the error on line 49. i'm very lost here, is there something else that i am missing or not doing.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/193811-parse-error-message/#findComment-1021016
Share on other sites

You may find it more particle to use HEREDOC syntax:

if ($fp)
{
    $content = <<<PHPCODE
<?php

/* Database Host Name */ 
\$db_host = '{$post_details['db_host']}';

/* Database Username */
\$db_username = '{$post_details['db_username']}';

/* Database Login Password */
\$db_password = '{$post_details['db_password']}';

/* Database and Session prefixes */
define('DB_PREFIX', '{$post_details['table_prefix']}'); ## Do not edit !
define('SESSION_PREFIX', 'probid_');

/* Database Name */
\$db_name = '{$post_details['db_name']}';

?>
PHPCODE;

      fputs($fp, $content); 
      fclose($fp);
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/193811-parse-error-message/#findComment-1021021
Share on other sites

thanks for the reply but now i'm getting a different error:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in C:\www\myserver.dev\public_html\........\install\install.php on line 52

 

## install related functions

function create_config($post_details)

{

$fp = fopen('../includes/config.php', 'w');

 

if ($fp)

{

    $content = <<<PHPCODE

<?php

 

/* Database Host Name */

\$db_host = '{$post_details['db_host']}';                  =>Line 52

 

/* Database Username */

\$db_username = '{$post_details['db_username']}';

 

/* Database Login Password */

\$db_password = '{$post_details['db_password']}';

 

/* Database and Session prefixes */

define('DB_PREFIX', '{$post_details['table_prefix']}'); ## Do not edit !

define('SESSION_PREFIX', 'probid_');

 

/* Database Name */

\$db_name = '{$post_details['db_name']}';

 

?>

PHPCODE;

 

      fputs($fp, $content);

      fclose($fp);

}

Link to comment
https://forums.phpfreaks.com/topic/193811-parse-error-message/#findComment-1021055
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.