Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End how to insert config.php data from install.php

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #44613
    amis
    Participant

    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

    #135051
    Rohithzr
    Participant

    well really cant understand you completely but still i will try to answer
    calling data from another file :
    connect.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

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

    #135125
    johncruz
    Member

    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”);

    ?>

    #135223
    amis
    Participant

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

    how to do this ?

    #135253
    __
    Participant

    > 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](https://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.

    #135513
    amis
    Participant

    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

    #135586
    __
    Participant

    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)
  • The forum ‘Back End’ is closed to new topics and replies.