[SOLVED] PHP database code issue

This is a discussion on "[SOLVED] PHP database code issue" within the PHP Forum section. This forum, and the thread "[SOLVED] PHP database code issue are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #41  
Old Mar 25th, 2008, 23:25
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

when the page blank, look at the source. anything there?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #42  
Old Mar 25th, 2008, 23:40
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

No but I think there is something wrong with the code, as the code is red after the last ?>
I'll upload code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #43  
Old Mar 25th, 2008, 23:40
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

Code: Select all
<head>
<title>Account Details</title></head>


<html>
<style type="text/css">
<!--
@import url("default.css");
<!--
body {
    background-repeat: repeat-x;
}
-->
</style>
<body>
<div id="header">
<script>
var Digital=new Date()
var month=Digital.getMonth()
if (month <= 2){    // month is between jan and march    
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img5.jpg'>");
} else if (month <= 5){
    // month is between april and june
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img2.jpg'>");
} else if (month <= 8){    // july and september
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img2.jpg'>");
} else {    // otherwise its between oct and dec
    document.write("<IMG SRC='http://www.lightex.co.uk/fieldworks/images/img3.jpg'>");
}
</script>
</div>
<div id="page">
  <div id="content">
        <div id="welcome" class="post">
            <h1 class="title">Account Details</h1>
            <div class="content"><img src="http://www.webforumz.com/images/420 copy.png" alt="" width="131" height="106" class="left" />
                <h3 align="center"><br />
                </h3>
                <h3 align="center">The professional approach to paddock maintenance.</h3>
          </div>
    </div>
        <div id="example" class="post">
            <h2 class="title">&nbsp;</h2>
            
<?php
ob_start()
$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name=""; // Table name

    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    m// issue the query
    $sql = "SELECT * FROM members WHERE
            username = '".$_POST["username"]."' AND
            password = '".$_POST["password"]."'; 
    $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
    if($info = mysqli_fetch_array($result)) { 
            //display string
       $display_block = "
    <p>".$info['f_name']." <p>
    <p>".$info['l_name']." <p>"; 

    echo $display_block; 
    } else {
       echo '<p>Wrong username and password!</p>';
    } 
    ?>


            
            <div class="content">
                                  
              
          </div>
        </div>
  </div>
    <div id="sidebar">
        <div id="menu">
            <ul>
              <li><a href="homepage.html" onclick="logout_confirm(); return false;">Homepage</a>
             <script> function logout_confirm() {
  if(confirm("You are about to logout?"))
    window.location = "homepage.html";
}</script></li>
                <li><a href="login_success.php" title="">Login Homepage</a></li>
              <li><a href="fieldworks/accountdetails.php" title="">Account Detail</a></li>
                <li><a href="lastbill.php" title="">Last Bill</a></li>
                <li><a href="estatedetails.php" title="">Estate Details</a></li>
                <li><a href="fieldworks/contactuslogin.php" title="">Contact Us</a></li>
            </ul>
        </div>
        <div id="login" class="boxed">
            <h2 class="title">Next Vistit</h2>
            <div class="content">
            
          </div>
        </div>
        <div id="updates" class="boxed">
            <h2 class="title">Time</h2>
            <div class="content">
                <!-- Paste this code into the BODY section of your HTML document  -->


            </div>
        </div>
    </div>
    <div style="clear: both;">&nbsp;</div>
</div>
<div id="footer">Copyright &copy; 2008 fieldworks.com. Designed by <a href="ttp://www.blanedesigns.com">Blane Designs</a>
  <p id="links"><br />
  <a href="#">Privacy Policy</a></p>
</div>
</body>
</html>

Last edited by acrikey; Mar 26th, 2008 at 11:08.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #44  
Old Mar 25th, 2008, 23:42
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

is it saved as a .php file?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #45  
Old Mar 25th, 2008, 23:42
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

yes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #46  
Old Mar 25th, 2008, 23:46
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

is this on your local machine or a host? Does your host support PHP?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #47  
Old Mar 25th, 2008, 23:46
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

http://www.lightex.co.uk/fieldworks/accountdetails.php

Alert Box UN: test
Alert box PW: webforumz

site UN: webforumz
site PW: webforumz
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #48  
Old Mar 25th, 2008, 23:46
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

host and yes they can support php5
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #49  
Old Mar 26th, 2008, 00:00
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

PHP: Select all

<?php
ob_start
()
$host="localhost"// Host name
$username="fieldworks"// Mysql username
right there. Get rid of that ob_start(). You don't need it and that most likely is whats causing the problems.
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #50  
Old Mar 26th, 2008, 11:11
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

Still blank and the ob is removed
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #51  
Old Mar 26th, 2008, 14:14
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

just as a test, insert this somewhere in your PHP code:

PHP: Select all

nonexistant("asdfasd); 

See if that returns any sort of error.
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #52  
Old Mar 26th, 2008, 14:23
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

Still blank, nothing returned
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #53  
Old Mar 26th, 2008, 14:26
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

are any other PHP pages working?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #54  
Old Mar 26th, 2008, 14:36
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

none with this code but others yes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #55  
Old Mar 26th, 2008, 14:38
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

hmmmm

contact your host. tell them nothing is displaying, including errors.
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #56  
Old Mar 26th, 2008, 14:43
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

But surely it must be the code because, it displays until I put the db code in the script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #57  
Old Mar 26th, 2008, 14:46
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,267
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: PHP database code issue

im pretty sure it is the code also, but the code must have a fatal error if its not displaying anything, and its not showing the fatal error. so contact your host about its PHP error settings.
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #58  
Old Mar 26th, 2008, 14:49
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP database code issue

hang on I'll just run a quick test, bare with me
Digg this Post!