0

I have an index.php page that includes settings.php

in the settings.php file, I have some PHP Variables with data, like phone numbers, names etc.

on my index.php file i am selecting data from a MySQL table and echoing it on the screen, i want to be able to have the variables from the settings.php file in the database so they will echo on the index.php page

how is this possible?

1
  • Surely you would first just need to insert that data into your database first. You can do that in your PHP if you want it to run every time. Or even just simply using the prompt to perform an insert query. Commented Oct 29, 2013 at 10:35

2 Answers 2

2

I hope this is what you are looking for.

settings.php

<?php
$valueFromSettings="Settings.php";

Index.php

<?php
include("settings.php");
echo $valueFromSettings; //Prints Settings.php

Alternatively, you can make use of include_once(), require(), require_once() .. all of these are language constructs.. but beware of require() and require_once() as they spit FATAL errors if your PHP file to be included does not exist.

Sign up to request clarification or add additional context in comments.

Comments

0

settings.php

 <?php
  $phone='12345';
  //declare all of your variables here
 ?>

and in index.php get these variables as

<?php
 include(settings.php);
 $query='SELECT phone FROM table where phone="'.$phone.'"';

?>

Hope it will help you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.