+ Reply to Thread
Results 1 to 9 of 9

Thread: PHP Code returns blank page...

  1. #1
    mattjs92's Avatar
    mattjs92 is offline x10Hosting Member mattjs92 is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    canada
    Posts
    4

    PHP Code returns blank page...

    <?php
    $con = mysql_connect("***","***","***") or die('Could not connect: ' . mysql_error());
    $dbconnect = mysql_select_db("***", $con) or die ("could not connect to database: " . mysql_error());
    if($_SESSION['username']=="***")
    {
    if ($_POST['title'] && $_POST['description'])
    {
    $check = mysql_query("INSERT INTO links (title, description) VALUES ('$_POST[title]', '$_POST[description]')") or die("Could not add content to database: " . mysql_error());
    echo "<p>Link Added Successfully.</p>";
    }
    elseif ($_POST['title'] || $_POST['description'])
    {
    $title1 = $_POST['title'];
    $description1 = $_POST['description'];
    }
    if ($_GET[successful]==1)
    {
    echo "<p>Link Edited Successfully.</p>";
    }
    echo "<form action='links.php' method='post'>
    <p><b>Link Title</b><br/>
    <input type='text' style='width:690px;' id='title' value='" . $title1 . "'/><br/><br/>
    <b>URL: http</b><br/>
    <input type='text' style='width:690px;' id='description' value='" . $description1 . "'/></p>
    </form>";
    $result = mysql_query("SELECT * FROM links") or die("Could not get link data: " . mysql_error());
    while($row = mysql_fetch_array($result))
    {
    echo "<p><a href='" . $row['description'] . "'>" . $row['title'] . "</a></p><a href='edit.php?id=" . $row['id'] . "&page=links&redirect=links.php' onclick='return editEvent();'>Edit</a> | <a href='delete.php?did=" . $row['id'] . "&page=links&redirect=links.php' onclick='return doubleCheck();'>Delete</a>";
    }
    }
    else
    {
    $result = mysql_query("SELECT * FROM links") or die("Invalid Query: " . mysql_error());
    while($row = mysql_fetch_array($result))
    {
    echo "<p><a href='" . $row['description'] . "'>" . $row['title'] . "</a></p>
    }
    }
    mysql_close($con);
    ?>
    Last edited by mattjs92; 06-19-2009 at 03:44 PM.

  2. #2
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: PHP Code returns blank page...

    Firstly, is this on your home server or on X10? I had a home server with the same problem, and it turns out PHP has reporting errors disabled by default in the php.ini file. In error, the browser would return a blank page.
    Last edited by Twinkie; 06-19-2009 at 03:49 PM.

  3. #3
    mattjs92's Avatar
    mattjs92 is offline x10Hosting Member mattjs92 is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    canada
    Posts
    4

    Re: PHP Code returns blank page...

    im on the wrong forum... SORRY!
    Last edited by mattjs92; 06-19-2009 at 03:58 PM.

  4. #4
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: PHP Code returns blank page...

    Your scripts don't have to be hosted on x10 to get community support, if I understand this correctly?

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP Code returns blank page...

    When asking questions about code:
    • Include a description of what you want the code to do and what it actually does in the body of the message.
    • Make sure the code you post is a minimal test case. The code you posted is fairly minimal, but doesn't look complete.
    • format the code to make it readable. This means indent (using a variant of a standard indent style) and (for these forums) encase the code in [PHP], [HTML] or [CODE] tags to preserve the indentation. If you use an editor designed for coding, it will indent the code for you. Here's the result of indenting your code in emacs (ESC ^\) and putting it in [PHP] tags:
      PHP Code:
      <?php
      $con 
      mysql_connect("***","***","***") or die('Could not connect: ' mysql_error());
      $dbconnect mysql_select_db("***"$con) or die ("could not connect to database: " mysql_error());
      if(
      $_SESSION['username']=="***")
      {
          if (
      $_POST['title'] && $_POST['description'])
          {
              
      $check mysql_query("INSERT INTO links (title, description) VALUES ('$_POST[title]', '$_POST[description]')") or die("Could not add content to database: " mysql_error());
              echo 
      "<p>Link Added Successfully.</p>";
          }
          elseif (
      $_POST['title'] || $_POST['description'])
          {
              
      $title1 $_POST['title'];
              
      $description1 $_POST['description'];
          }
          if (
      $_GET[successful]==1)
          {
              echo 
      "<p>Link Edited Successfully.</p>";
          }
          echo 
      "<form action='links.php' method='post'>
      <p><b>Link Title</b><br/>
      <input type='text' style='width:690px;' id='title' value='" 
      $title1 "'/><br/><br/>
      <b>URL: http</b><br/>
      <input type='text' style='width:690px;' id='description' value='" 
      $description1 "'/></p>
      </form>"
      ;
          
      $result mysql_query("SELECT * FROM links") or die("Could not get link data: " mysql_error());
          while(
      $row mysql_fetch_array($result))
          {
              echo 
      "<p><a href='" $row['description'] . "'>" $row['title'] . "</a></p><a href='edit.php?id=" $row['id'] . "&page=links&redirect=links.php' onclick='return editEvent();'>Edit</a> | <a href='delete.php?did=" $row['id'] . "&page=links&redirect=links.php' onclick='return doubleCheck();'>Delete</a>";
          }
      }
      else 
      {
          
      $result mysql_query("SELECT * FROM links") or die("Invalid Query: " mysql_error());
          while(
      $row mysql_fetch_array($result))
          {
              echo 
      "<p><a href='" $row['description'] . "'>" $row['title'] . "</a></p>
      }
      }
      mysql_close(
      $con);
      ?>
      Notice how the closing bracket for the last while loop isn't indented and the code is red? This is a clue that there is a syntax problem before the bracket, something that prevented emacs' auto-indent from working. The red text (here it means the text is in a string) is another clue, one that means you've got an unterminated string. Looking at the line above and you'll see it. Notice the line is also missing its line-ending semicolon. Also, there's no need for string concatenation (the "." operator) with echo as it's variadic (it supports a variable number of arguments). You can separate each string to be printed with a comma. Lastly, if you don't need variable interpolation, try single quoted strings:
      PHP Code:
              echo '<p><a href="'$row['description'], '">'$row['title'], '</a></p>'
      Normally, you shouldn't be too concerned with this sort of micro-optimization 2) and shouldn't optimize too early, but the above tips are good when you're writing new code (except perhaps single quoting). The best (ie most readable and not slower in a big-O sense) code is probably:
      PHP Code:
              echo "<p><a href='$row[description]'>$row[title]</a></p>"

    PHP Code:
    <?php
    $con 
    mysql_connect("***","***","***") or die('Could not connect: ' mysql_error());
    die() can be OK for test code, but not production code (2). Also, printing MySQL error information can disclose too much information. Moreover, the information will likely be useless and unintelligible for most users of your site (the ones who can understand and use it are the ones you need to worry about).

    PHP Code:
    if($_SESSION['username']=="***"
    You need to call session_start() before you can access $_SESSION

    PHP Code:
    {
        if (
    $_POST['title'] && $_POST['description'])
        {
            
    $check mysql_query("INSERT INTO links (title, description) VALUES ('$_POST[title]', '$_POST[description]')") or die("Could not add content to database: " mysql_error()); 
    Placing user input directly into a query opens your script to SQL injection (2). Never do this. Instead, filter the data using PHP's filter functions or the DB driver's escape function (e.g. mysql_escape_string, mysqli_real_escape_string, pg_escape_string). Even better is to use prepared statements, if the driver supports them (e.g. mysqli_prepare, PDO::prepare).

    PHP Code:
        if ($_GET[successful]==1
    This looks wrong for two reasons: if "successful" is a string index, it should be quoted (it should remain unquoted only if it's a constant). The second comes mostly from intuition and is harder to put into words, but it involves the fact that $_GET is filled from the query string for the current page.

    HTML Code:
    <form action='links.php' method='post'>
    <p><b>Link Title</b><br/>
    <input type='text' style='width:690px;' id='title' value='" . $title1 . "'/><br/><br/>
    <b>URL: http</b><br/>
    <input type='text' style='width:690px;' id='description' value='" . $description1 . "'/></p>
    </form>
    Use inline style sparingly. Also, avoid using <br /> for layout. px units are mostly appropriate for images; use ems with text & text widgets. Try the following structure:
    HTML Code:
    <form action='links.php' id="linkEdit" method='post'>
    <label for="title">Link Title</label>
    <input type='text' id='title' value='" . $title1 . "'/>
    <label for="description">URL: http</label>
    <input type='text' id='description' value='" . $description1 . "'/>
    </form>
    with the following style:
    Code:
    form#linkEdit input {
      width: 40em;
      display: block;
      margin-bottom: 1em;
    }
    form#linkEdit label {
      display: block;
    }
    form#linkEdit input:last-child {
      margin-bottom: 0;
    }
    Last edited by misson; 06-19-2009 at 07:36 PM.

  6. #6
    taha116's Avatar
    taha116 is offline x10 Lieutenant taha116 is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    497

    Re: PHP Code returns blank page...

    I am having the same blank page problem on lotus and it was always working, i made no modifications? Is this also due to the changes on the servers?


    Need help with starting up your website? No problemo PM if you need help, if you want help with scripts like WordPress, SMF and so on dont be afraid to PM for that too.


  7. #7
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: PHP Code returns blank page...

    Well, in mattjs92 case, it was because of poorly built code. Since you are on lotus, this could be due to the server moves... However, since lotus is supposed to be fully transferred, you should and are entitled to posting a support ticket.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  8. #8
    taha116's Avatar
    taha116 is offline x10 Lieutenant taha116 is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    497

    Re: PHP Code returns blank page...

    Yay I just submitted one even though i was afraid of getting banned, now i feel more secure about my ticket


    Need help with starting up your website? No problemo PM if you need help, if you want help with scripts like WordPress, SMF and so on dont be afraid to PM for that too.


  9. #9
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: PHP Code returns blank page...

    I just went over the announcements (this should be the first thing every member does when accessing the forum), and Corey clearly states that Lotus is supposed to be completely transferred. http://forums.x10hosting.com/news-an...6-18-09-a.html and http://forums.x10hosting.com/news-an...6-14-09-a.html is were he states it. Mainly, the problem is from starka users. I've been moved from stoli to chopin during the move, and it's behaving like a charm, so I'm kinda happy!
    Last edited by xav0989; 06-21-2009 at 09:31 PM.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

+ Reply to Thread

Similar Threads

  1. how can i convert Php pages and code into asp pages and code
    By n4tec in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 01-10-2009, 09:40 PM
  2. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  3. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  4. BB Code Guide
    By Jober68 in forum Tutorials
    Replies: 1
    Last Post: 01-10-2008, 05:12 PM
  5. PHP Mail Code Problem
    By Swiblet in forum Free Hosting
    Replies: 2
    Last Post: 11-04-2007, 08:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers