Closed Thread
Results 1 to 3 of 3




  

Thread: php5+ and Include('dbconnect.php')

      
  1. #1
    The Force is Strong! lucifersangel87 is on a distinguished road lucifersangel87's Avatar
    Join Date
    May 13, 2010
    Location
    The Midlands, England
    Posts
    11
    Rep Power
    3
    Feedback Score
    0

    Default php5+ and Include('dbconnect.php')

    Hi guys,

    I regularly use a dbconnect script which is taking up a lot of room on my php scripts.

    I've tried taking it out into a dbconnect.php file and using the old
    PHP Code:
    include('dbconnect.php'); 
    method. However, include simply does not want to work for this file!!

    I have put an echo line into my dbconnect.php file as a debug idicator but as such it is not displaying.

    Has anyone got any ideas?

    index.php:
    PHP Code:
    include('dbconnect.php');
    $result mysql_query("SELECT * FROM $table");

                    

                    
    $count=mysql_num_rows($result);

                    while(
    $i $count) {

                    

                    
    $shortname mysql_result($result$i2);

                    
    $sname mysql_result($result$i1);

                    

                    echo 
    '<option value="index.php?page=rallydiary&s=' $shortname '&p=1">' $sname '</option>';

                    

                    
    $i++;

                    } 

    my dbconnect.php script:

    PHP Code:
                    $host="localhost"// Host name         

                    
    $username="..."// Mysql username         

                    
    $password="..."// Mysql password         

                    
    $db_name="..."// Database name 

                    
    $table="sections"// Table Name


                    
    $i 0;

                    echo 
    "you are using dbconnect.php";

                    
    $con mysql_connect("$host""$username""$password");

                    if (!
    $con)

                    {

                        die(
    "cannot connect"); 

                    };

                    
    mysql_select_db("$db_name")or die("cannot select DB");

                    

                    
    $result mysql_query("SELECT * FROM $table"); 

  2. #2
    Jedi Master sandeep Kumar is on a distinguished road
    Join Date
    June 24, 2010
    Location
    India
    Posts
    35
    Rep Power
    2
    Feedback Score
    0

    Arrow Re: php5+ and Include('dbconnect.php')

    Hi , Here we just introduce what & how we use include in my application:
    Basic Concept: The include() statement includes and evaluates the specified file.
    vars.php

    <?php
    $color = 'green';
    $fruit = 'apple';
    ?>

    test.php

    <?php
    include 'vars.php';
    echo "A $color $fruit"; // A green apple
    ?>

    and if it cannot find a file, then include() generate a warning.

  3. #3
    Jedi Master waynewex is on a distinguished road
    Join Date
    August 16, 2010
    Posts
    25
    Rep Power
    2
    Feedback Score
    0

    Default Re: php5+ and Include('dbconnect.php')

    Is your server set to show errors? Are you absolutely sure that dbconnect.php is in the right folder, because I'm guessing that it's not, especially if your echo statement is being shown.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. How to Include a php file directly to phpfox html file
    By vineethclm in forum Programming
    Replies: 9
    Last Post: Dec 29th, 2011, 7:31 pm
  2. Include a new module/section into phpFox
    By vineethclm in forum Programming
    Replies: 2
    Last Post: Oct 20th, 2008, 2:02 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
WebTalkForums
WebTalkForums
Recent Forum Threads