error anyone?

Discussion in 'PHP' started by webber09, Jan 22, 2011.

  1. #1
    can anyone see an error in this code :S??

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?
    echo '<h1>Registered Users</h1>';
    
    require_once ('mysqli_connect.php');
    $q = "select concat(last_name, ', ', first_name) as name,
    date_format(registration_date, '%m %d, %y') as fr from users order by registration_date asc";
    
    $r = @mysqli_query ($dbc, $q);
    
    if ($r) {
    	echo '<table align="center" cellspacing="3" cellpadding="3" width="75%">
    	<tr>
    	<td align="left"><b>Name</b></td>
    	<td align="left"><b>Date Registered</b></td>
    	</tr>';
    	
    	while ($row = mysqli_fetch_array($r, mysqli_assco)) {
    		echo '<tr><td align="left">' . $row['name'] . '</td>
    		<td align="left">' . $row['dr'] . '</td>
    		</tr>';
    	}
    	echo '</table>';
    	
    	mysqli_free_result ($r);
    } else {
    	echo '<p>The Current users could not be retrieved</p>';
    	echo '<p>' . mysql_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
    }
    	
    	mysqli_close($dbc);
    ?>
    </body>
    </html>
    PHP:
     
    webber09, Jan 22, 2011 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Eh,,,
    This
    
    $q = "select concat(last_name, ', ', first_name) as name,
    date_format(registration_date, '%m %d, %y') as fr from users order by registration_date asc";
    
    PHP:
    Should be this: (one line)
    
    $q = "select concat(last_name, ', ', first_name) as name, date_format(registration_date, '%m %d, %y') as fr from users order by registration_date asc";
    
    PHP:
     
    MyVodaFone, Jan 22, 2011 IP
    webber09 likes this.
  3. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #3
    still nothing, i have copy and pasted yours. this is how it shows here
     
    Last edited: Jan 22, 2011
    webber09, Jan 22, 2011 IP
  4. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #4
    It doesn't matter if it's on one line or not. What's it outputting? The PHP looks fine, looks to be something to do with the query.

    Try this to see if there is an error:
    $r = mysqli_query ($dbc, $q) or die( mysqli_error($dbc ) );
    PHP:
     
    Alex Roxon, Jan 22, 2011 IP
  5. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #5
    does you `users` table contain at least 1 row?
     
    G3n3s!s, Jan 22, 2011 IP
  6. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #6
    basically it should put out the users in the mysql database and put them into a table ordered by the date they signed up. i have seen this script exactly how i have written it in a book called 'php 6 and mysql 5' by visual quickpro guide and larry ullman. so it should work!
     
    webber09, Jan 22, 2011 IP
  7. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #7
    but, do you have any rows in users table? Please export that table with data via phpmyadmin, thanks
     
    G3n3s!s, Jan 22, 2011 IP
  8. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #8
    this is what is in the users table in the db...

    -- phpMyAdmin SQL Dump
    -- version 3.2.5
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Jan 22, 2011 at 11:30 PM
    -- Server version: 5.1.48
    -- PHP Version: 5.2.17

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

    --
    -- Database: `web111-members-2`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `users`
    --

    CREATE TABLE `users` (
    `user_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
    `first_name` varchar(20) NOT NULL,
    `last_name` varchar(40) NOT NULL,
    `email` varchar(80) NOT NULL,
    `pass` char(40) NOT NULL,
    `registration_date` datetime NOT NULL,
    PRIMARY KEY (`user_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

    --
    -- Dumping data for table `users`
    --

    INSERT INTO `users` (`user_id`, `first_name`, `last_name`, `email`, `pass`, `registration_date`) VALUES
    (1, 'Lloyd', 'Dear', 'management@xpresscenter.co.uk', 'd1fb70ff8f817945b31b369177a44ec237a8a3d6', '2011-01-22 17:01:03');
     
    webber09, Jan 22, 2011 IP
  9. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #9
    okaay try this code
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?
    echo '<h1>Registered Users</h1>';
    
    require_once ('mysqli_connect.php');
    $q = "select first_name, last_name, registration_date from users order by registration_date asc";
    
    $r = @mysqli_query ($dbc, $q);
    
    if ($r) {
        echo '<table align="center" cellspacing="3" cellpadding="3" width="75%">
        <tr>
        <td align="left"><b>Name</b></td>
        <td align="left"><b>Date Registered</b></td>
        </tr>';
        
        while ($row = mysqli_fetch_array($r, mysqli_assco)) {
            echo '<tr><td align="left">' . $row['first_name'] . ' '. $row['last_name'] .'</td>
            <td align="left">' . $row['registration_date'] . '</td>
            </tr>';
        }
        echo '</table>';
        
        mysqli_free_result ($r);
    } else {
        echo '<p>The Current users could not be retrieved</p>';
        echo '<p>' . mysql_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
    }
        
        mysqli_close($dbc);
    ?>
    </body>
    </html>
    PHP:
     
    G3n3s!s, Jan 22, 2011 IP
  10. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #10
    Last edited: Jan 22, 2011
    webber09, Jan 22, 2011 IP
  11. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #11
    I think I got it
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?
    echo '<h1>Registered Users</h1>';
    
    require_once ('mysqli_connect.php');
    $q = "select first_name, last_name, registration_date from users order by registration_date asc";
    
    $r = @mysqli_query ($dbc, $q);
    
    if ($r) {
        echo '<table align="center" cellspacing="3" cellpadding="3" width="75%">
        <tr>
        <td align="left"><b>Name</b></td>
        <td align="left"><b>Date Registered</b></td>
        </tr>';
        
        while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
            echo '<tr><td align="left">' . $row['first_name'] . ' '. $row['last_name'] .'</td>
            <td align="left">' . $row['registration_date'] . '</td>
            </tr>';
        }
        echo '</table>';
        
        mysqli_free_result ($r);
    } else {
        echo '<p>The Current users could not be retrieved</p>';
        echo '<p>' . mysql_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
    }
        
        mysqli_close($dbc);
    ?>
    </body>
    </html>
    PHP:
    mysqli_assco
    MYQLI_ASSOC ;)
     
    G3n3s!s, Jan 22, 2011 IP
  12. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #12
    it works !
    I am good :D xpresscenter.co.uk/loginarea/view_users.php
    Congratz ;)

    I want your style on xpresscenter.co.uk :D
    Where did you find it ?
     
    G3n3s!s, Jan 22, 2011 IP
  13. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #13
    YYYYYYAAAAAYYYYYY thank you sssooooo much... take a look now :D
     
    webber09, Jan 22, 2011 IP
  14. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #14
    I know :p I noticed it just few seconds after you edited it ;)
    I want your style on xpresscenter.co.uk
    Where did you find it ?
     
    G3n3s!s, Jan 22, 2011 IP
  15. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #15
    i am a website designer :D i just dont do the PHP side of things much, just getting onto it. i designed it myself
     
    webber09, Jan 22, 2011 IP