Grow your CSS skills. Land your dream job.

how to insert config.php data from install.php

  • # May 7, 2013 at 12:09 pm

    I have been built script and make install.php for my script

    I want insert data of servername , user , password , database in install.php like installation in wordpres

    # May 14, 2013 at 2:40 pm

    well really cant understand you completely but still i will try to answer
    calling data from another file :
    connect.php

    < ?php
    //connect.php
    session_start();
    $server = ‘localhost';
    $username = ‘a491_rohit';
    $password = ‘pass';
    $database = ‘forum_db';

    if(!mysql_connect($server, $username, $password))
    {
    exit(‘Error: could not establish database connection’);
    }
    if(!mysql_select_db($database))
    {
    exit(‘Error: could not select the database’);
    }
    ?>
    then : header.php

    < ?php
    include ‘connect.php';
    if(isset($_SESSION) && $_SESSION == true){
    echo ‘
    $_SESSION;
    $_SESSION
    ‘;
    }
    hope it helps

    # May 15, 2013 at 3:19 am

    Sorry but i didn’t get your point what are you trying to say. But I am trying to answer your question. I hope it will help you.

    Try this.

    This script will create tables and load data from an sql file.

    < ?
    function run_query_batch($handle, $filename=””)
    {
    //


    // Open SQL file.
    //


    if (! ($fd = fopen($filename, “r”)) ) {
    die(“Failed to open $filename: ” . mysql_error() . “
    “);
    }

    //


    // Iterate through each line in the file.
    //


    while (!feof($fd)) {

    //


    // Read next line from file.
    //


    $line = fgets($fd, 32768);
    $stmt = “$stmt$line”;

    //


    // Semicolon indicates end of statement, keep adding to the statement.
    // until one is reached.
    //


    if (!preg_match(“/;/”, $stmt)) {
    continue;
    }

    //


    // Remove semicolon and execute entire statement.
    //


    $stmt = preg_replace(“/;/”, “”, $stmt);

    //


    // Execute the statement.
    //


    mysql_query($stmt, $handle) ||
    die(“Query failed: ” . mysql_error() . “
    “);

    $stmt = “”;
    }

    //


    // Close SQL file.
    //


    fclose($fd);
    }

    run_query_batch($dbhandle, “schema.sql”);

    ?>

    # May 15, 2013 at 4:53 pm

    thx alot
    but fopen() need 0777 permation to can open file and write on it

    how to do this ?

    __
    # May 16, 2013 at 1:12 am

    > thx alot but fopen() need 0777 permation to can open file and write on it

    @johncruz ‘s script does not involve writing to the file (in fact, he opens the file in read-only mode).

    > how to do this ?

    Is this related to your [`chmod` thread](http://css-tricks.com/forums/discussion/24856/problem-with-chmod-function)? You never responded to my question there. It is likely the same answer will apply here.

    In general, you will get more help (also, *better* help) if you provide more information and respond to people’s questions about your situation.

    Take your original post, for example:

    > I have been built script and make install.php for my script

    > I want insert data of servername , user , password , database in install.php like installation in wordpres

    This is very vague. You don’t say what your problem is, or even if you actually *have* a problem. You do not ask a question. Instead, you leave everyone to guess for themselves what you want.

    # May 18, 2013 at 7:21 am

    Thx traq very much
    the problem is english not my native language but i will take with your advices
    but untill this moment don’t know the solution

    __
    # May 19, 2013 at 12:39 am

    I mean no offense. This has nothing to do with what language we all speak.

    If you want an answer to a question, you need to *ask* a question. If you don’t, then everyone is simply left to guess what you want. They probably won’t be right.

    Likewise, if I ask you a question about your problem, and you simply ignore it, it is unlikely that I’ll be able to find a useful answer for you.

    I don’t expect you to “take my advice” or “do what I say” or apologize for not having a solution or anything like. I’d like to work together with you to help you solve your problem. I can’t do that without knowing *what you need to solve*.

    So,

    **… What is the problem you need to solve?**

    Are you trying to create a database connection, as @Rohitzhzr thought?

    Are you trying to import data into your database, as @johncruz thought?

    Are you trying to do something else entirely?

    Please explain: 1) what you are trying to accomplish, 2) what you have already tried, and 3) which part you have trouble with.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".