Problem in my line of code: Please help

  • christogonus
  • Born
  • Born
  • christogonus
  • Posts: 1

Post 3+ Months Ago

I have the code below in my php work but it shows error.


PHP Code: [ Select ]
 
$main_path = "C:\xampp\htdocs\keleobasi\";
$include_path = "C:\xampp\htdocs\keleobasi\includes\";
 
 
  1.  
  2. $main_path = "C:\xampp\htdocs\keleobasi\";
  3. $include_path = "C:\xampp\htdocs\keleobasi\includes\";
  4.  
  5.  



the trailing backslash (\) before the closing double quote (") makes the PHP see it that the string is not yet finished. Someone help
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

What you need to do is escape all of your trailing backslashes so that it see it as a backslash and not your intention to escape the quote. So you would make it look like:

PHP Code: [ Select ]
$main_path = "C:\\xampp\\htdocs\\keleobasi\\";
$include_path = "C:\\xampp\\htdocs\\keleobasi\\includes\\";
  1. $main_path = "C:\\xampp\\htdocs\\keleobasi\\";
  2. $include_path = "C:\\xampp\\htdocs\\keleobasi\\includes\\";
  • Satwant
  • Graduate
  • Graduate
  • User avatar
  • Posts: 127
  • Loc: Bangalore

Post 3+ Months Ago

Or just use forward slash instead of backward slash. IT usually make no difference if used with standard php file functions.

Code: [ Select ]
$main_path = "C:/xampp/htdocs/keleobasi/";
$include_path = "C:/xampp/htdocs/keleobasi/includes/";
  1. $main_path = "C:/xampp/htdocs/keleobasi/";
  2. $include_path = "C:/xampp/htdocs/keleobasi/includes/";
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

A couple other ways:

After defining, trim the trailing slash:
PHP Code: [ Select ]
$include_path = rtrim($include_path, '/');
$main_path = rtrim($main_path, '/');
 
  1. $include_path = rtrim($include_path, '/');
  2. $main_path = rtrim($main_path, '/');
  3.  


Or, use single quotes to avoid interpretation:
PHP Code: [ Select ]
$include_path = 'C:/xampp/htdocs/keleobasi/includes/';
$main_path = 'C:/xampp/htdocs/keleobasi/';
 
  1. $include_path = 'C:/xampp/htdocs/keleobasi/includes/';
  2. $main_path = 'C:/xampp/htdocs/keleobasi/';
  3.  

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 70 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.