Jump to content

Recommended Posts

Hello everyone,

 

I have a file called config.php which has the following in it...

 

<?php
$hostname = "localhost";
$database = "database";
$username = "username";
$password = "password";
?>

I am trying to write stuff in between the <?php ?> tags but without deleting what is already in the file.

 

How would I go about adding text to the middle of a file using PHP?

Link to comment
https://forums.phpfreaks.com/topic/164730-writing-to-the-middle-of-a-file/
Share on other sites

You should not mess with the configuration set in this file, this is helping you identify your MySQL server / login information.

 

$hostname is the address to your MySQL server.

$database is the name of the MySQL database the application will use.

$username is the username you most-likely log in with.

$password is the password you most-likely use to log in.

 

If you're looking to add more fields, which is highly unneeded and may potentially make this application not work, you would have to identify the variables such as

$security = "$_GET();

 

It's highly complex, especially if you're not that well in the PHP language.

So you basically just need to add text to the end of the file then. The closing ?> is not needed by php if you file contains php only, so just remove it and get on with the job.

 

Ok, good to know, thanks...

 

Just one other question, if I don't add the closing ?> but then include() or require() the file will it cause problems?

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.