Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Simple PHP / MySQL not working! Argh!
Old 11-03-2008, 05:56 PM Simple PHP / MySQL not working! Argh!
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
The problem I am having is that when I visit this page (memberlist.php if you were wondering), it is blank, no HTML, nothing.

OK, fair enough, at the moment, there's nothing in the DB, so it shouldn't be displaying rows and rows of information. But, it should still display the titles of the columns (because there's no 'if' or 'where', just 'echo')

PHP Code:
<?php

$con 
mysql_connect("localhost""username""password");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("database_name"$con);

$result mysql_query("SELECT * FROM tablename ORDER BY joined, name");

echo 
'<table width="100%" border="0">
  <tr>
    <td>#</td>
    <td>Name</td>
    <td>Role</td>
    <td>Joined</td>
    <td>GB Profile</td>
  </tr>'
;

while(
$row mysql_fetch_array($result))
    {
    echo 
"<table>
        <tr>
            <td>
$row['id']</td>
            <td>
$row['name']</td>
            <td>
$row['role']</td>
            <td>
$row['joined']</td>
            <td>
$row['gb']</td>
        </tr>
    </table>"
;
        
    echo 
"<br />";
    }
  
mysql_close($con);

?>
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-03-2008, 06:36 PM Re: Simple PHP / MySQL not working! Argh!
AliKat's Avatar
Extreme Talker

Latest Blog Post:
Save the Children
Posts: 176
Location: MS
Trades: 0
Are errors turned off on your php install? I don't catch anything in particular but I could be missing something.

But a few things that are incorrect. You open a table tag in your first echo and never close it, but you then open another table tag in your while statement and you close it there. It's an aweful lot of table tags to be in a long memberlist. Don't you think you should remove those tags and just close the whole table with anonther echo statment?

The only thing I can possibly think of is that echo might only work on a single line with '. Try making them " and escapting the quotes with \" and see if it echos out.
AliKat is offline
Reply With Quote
View Public Profile Visit AliKat's homepage!
 
Old 11-04-2008, 11:24 AM Re: Simple PHP / MySQL not working! Argh!
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
Quote:
Originally Posted by AliKat View Post
Are errors turned off on your php install? I don't catch anything in particular but I could be missing something.

But a few things that are incorrect. You open a table tag in your first echo and never close it, but you then open another table tag in your while statement and you close it there. It's an aweful lot of table tags to be in a long memberlist. Don't you think you should remove those tags and just close the whole table with anonther echo statment?

The only thing I can possibly think of is that echo might only work on a single line with '. Try making them " and escapting the quotes with \" and see if it echos out.
Thanks, you were right, php errors were turned off. I used a different server and followed the errors, it was the $_row[''] that was doing it, not sure why, but I used " instead of '
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 11-04-2008, 11:32 AM Re: Simple PHP / MySQL not working! Argh!
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 932
Trades: 7
btw Gilligan.. next time you have this issue to saved you moving to another server .. just wack..

Quote:
error_reporting(1)
in the top of your code to see the errors
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Reply     « Reply to Simple PHP / MySQL not working! Argh!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28790 seconds with 12 queries