PHP [Help] Page not displaying at all, when php code connects to MySQL Database
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: [Help] Page not displaying at all, when php code connects to MySQL Database

  1. #1
    Join Date
    Dec 2012
    Posts
    5

    [Help] Page not displaying at all, when php code connects to MySQL Database

    I have no idea what's wrong. I need personal help, I have next to 0 experience with PHP or MySQL. If someone could help me over skype or Teamviewer I'd be very grateful.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,869

    Re: [Help] Page not displaying at all, when php code connects to MySQL Database

    Typically in a forum, you state what your problem is. Please do so...
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Dec 2012
    Posts
    5

    Re: [Help] Page not displaying at all, when php code connects to MySQL Database

    Quote Originally Posted by PeejAvery View Post
    Typically in a forum, you state what your problem is. Please do so...
    Page goes blank when i upload all these files to it. Also viewsource: displays no code.

    PHP: http://pastebin.com/M9xyAVeX
    My main page (that won't display correctly): http://pastebin.com/PxgbRVNg

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,869

    Re: [Help] Page not displaying at all, when php code connects to MySQL Database

    If a server is displaying blank output, then you have server-side errors. Look at the PHP log.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Dec 2012
    Posts
    5

    Re: [Help] Page not displaying at all, when php code connects to MySQL Database

    There is no php error log displayed in the directory in which the php is being executed. :\

  6. #6
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,869

    Re: [Help] Page not displaying at all, when php code connects to MySQL Database

    There is no set location for it. You'll have to check the php.ini configuration file to see where it resides.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Dec 2012
    Posts
    5

    Re: [Help] Page not displaying at all, when php code connects to MySQL Database

    While access the php in the server I face error as shown below

    root@ [/home/microsof/public_html/generate]# php index.php

    Notice: Undefined index: REMOTE_ADDR in /home/microsof/public_html/getcodes/functions.php on line 92

    This is all the code in my functions.php file.
    PHP Code:
    <?php
    error_reporting
    (E_ALL); 
    ini_set('display_errors',1);
    function 
    getRandomString($length) {
        
    $characters '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        
    $string '';

        for (
    $i 0$i $length$i++) {
            
    $string .= $characters[mt_rand(0strlen($characters) - 1)];
        }

        return 
    $string;
    }

    function 
    new_ref()
    {
    $userip=$_SERVER['REMOTE_ADDR'];
    $query="SELECT * FROM cookie_ref_ips WHERE IP_address='$userip'";
    $exe=mysql_query($query);
    $num=mysql_num_rows($exe) or die(mysql_error());
    if (
    $num==0)
    {
    $refval=getRandomString(10);

    $query="SELECT * FROM cookie_ref_ips WHERE REF_val='$refval'";
    $exe=mysql_query($query);
    $num=mysql_num_rows($exe) or die(mysql_error());
    if(
    $num==0)
    {
    $query="INSERT INTO cookie_ref_ips(IP_address,REF_val) values('$userip','$refval')";
    mysql_query($query);
    $query="INSERT INTO cookie_ref(REF_hits,ip,REF_val) values('0','$userip','$refval')";
    mysql_query($query);
    }
    }
    $query="INSERT INTO cookie_ref(IP_address,REF_val) values('$userip','$refval')";

    }

    function 
    dbConnect() {
        
    // update this to your db details
        
    mysql_connect('localhost''microsof_user''cupcake123')or die(mysql_error());
        
    mysql_select_db('microsof_database')or die(mysql_error());
    }
        
    function 
    get_link()
    {
    $userip=$_SERVER['REMOTE_ADDR'];
    $query="SELECT * FROM cookie_ref_ips WHERE IP_address='$userip'";
    $exe=mysql_query($query);
    $exe2=mysql_fetch_array($exe) or die(mysql_error());
    $referal=$exe2['REF_val'];

    return 
    $referal;
    }    

    function 
    update_hits()
    {


    if(isset(
    $_GET['ref']))
    {
    $ip=$_SERVER['REMOTE_ADDR'];


    $ref=$_GET['ref'];


    $query="SELECT * FROM cookie_ref WHERE REF_val='$ref'";
    $exe=mysql_query($query);
    $result=mysql_fetch_array($exe);
    $Oip=$result['ip'];
    $hit_temp=$result['REF_hits'];
    $hit_temp++;


    if(
    $ip!=$Oip)
    {


    $query="UPDATE  cookie_ref set REF_hits='$hit_temp' WHERE REF_val='$ref'";
    mysql_query($query);
    }


    }

    }

    function 
    count_hits()
    {
    $userip=$_SERVER['REMOTE_ADDR'];
    $query="SELECT * FROM cookie_ref WHERE ip='$userip'";
    $exe=mysql_query($query);
    $result=mysql_fetch_array($exe) or die(mysql_error());

    $count=$result['REF_hits'];

    return 
    $count;



    }




    ?>
    Last edited by thepokemon; December 5th, 2012 at 11:32 AM.

  8. #8
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,869

    Re: [Help] Page not displaying at all, when php code connects to MySQL Database

    Since you have error reporting set to its highest level, it's going to fail on the smallest thing. In this case, it's because of server configuration using predefined variables. Although I have no clue why that one is...

    Try changing the error reporting to 0 instead of all, just for a test...
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center