SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 48 of 48
  1. #26
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here ya go....my table structure is -

    mysql> describe joke;
    +----------+---------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +----------+---------+------+-----+---------+----------------+
    | id | int(11) | NO | PRI | NULL | auto_increment |
    | joketext | text | YES | | NULL | |
    | jokedate | date | NO | | NULL | |
    +----------+---------+------+-----+---------+----------------+
    3 rows in set (0.02 sec)

  2. #27
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    What happens when from the mysql command line, you attempt to perform the troublesome query?

    Code:
    mysql> SELECT id, joketext FROM joke;
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #28
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works a treat......

    mysql> select id, joketext from joke;
    +----+-----------------------------------------------------------------+
    | id | joketext |
    +----+-----------------------------------------------------------------+
    | 1 | why did the chicken cross the road ? to get to the other side ! |
    | 2 | got the database working on the server at last. |
    | 3 | here's another naff joke
    |
    | 8 | can't think of another one ! |
    +----+-----------------------------------------------------------------+
    4 rows in set (0.02 sec)

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    That's good, so we can rule out the database as being involved in the trouble.

    Here's a crazy idea. We know that using "SELECT id, joketext FROM joke" from PHP is causing trouble. What happens when you use "SELECT * FROM joke" from PHP?

    Also, what does this show, when used after different types of selects?

    Code php:
    $result = mysqli_query('SELECT id, joketext FROM joke');
    var_dump('id, joketext:', mysql_num_rows($result));
     
    $result = mysqli_query('SELECT * FROM joke');
    var_dump('*:', mysql_num_rows($result));
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when i select * from joke - once again - i get the standard "cannot display page"....

    I tried your queries but got error messages which i believe is down to me running mysqli and not mysql.

    when i change the queries to mysqli then...
    ===============================
    $result = mysqli_query('SELECT id, joketext FROM joke');
    var_dump('id, joketext:', mysqli_num_rows($result));

    Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\index.php on line 84

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\index.php on line 85
    string(13) "id, joketext:" NULL
    Error fetching jokes:

    when i add $link to the mysqli_query ...
    $result = mysqli_query($link,'SELECT id, joketext FROM joke');
    i get the now infamous page..... "Internet Explorer cannot display the webpage"

    ===============================
    $result = mysqli_query('SELECT * FROM joke');
    var_dump('*:', mysqli_num_rows($result));

    result is :-
    Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\index.php on line 84

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\index.php on line 85
    string(2) "*:" NULL
    Error fetching jokes:

    if I add the link in -
    $result = mysqli_query($link,'SELECT * FROM joke');
    var_dump('*:', mysqli_num_rows($result));

    "Internet Explorer cannot display the webpage"

  6. #31
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by mingkwong View Post
    if I add the link in -
    $result = mysqli_query($link,'SELECT * FROM joke');
    var_dump('*:', mysqli_num_rows($result));

    "Internet Explorer cannot display the webpage"
    And that cannot be displayed is just from a test page itself, with no while conditions anywhere around?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #32
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've got a while further down..

    while ($row = mysqli_fetch_array($result))
    {
    $jokes[] = array('id' => $row['id'], 'text' => $row['joketext']);
    }

    but if i comment that while out then i get :-

    string(2) "*:" int(4) object(mysqli_result)#2 (0) { }
    Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\index.php on line 95

    Add your own joke

    Here are all the jokes in the database:


    Notice: Undefined variable: jokes in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\jokes.html.php on line 12

    Warning: Invalid argument supplied for foreach() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\jokes.html.php on line 12

  8. #33
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by mingkwong View Post
    i've got a while further down..
    I'm wanting to reduce your problem to only the bare minimum, in order to help narrow down the cause.

    Start with a completely fresh test file, and only put in the bare minimum to create the connection and perform the query.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #34
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok - can see where ya going.....

    the cut down script is now :

    =======================================================
    <?php
    ini_set('display_errors',1);
    error_reporting(E_ALL);

    $link = mysqli_connect('localhost', 'root', 'my_password');
    if (!mysqli_set_charset($link, 'utf8'))
    {
    $output = 'Unable to set database connection encoding.';
    include 'output.html.php';
    exit();
    }

    if (!mysqli_select_db($link, 'joke_db'))
    {
    $error = 'Unable to locate the joke database.';
    include 'error.html.php';
    exit();
    }

    $result = mysqli_query($link,'SELECT id, joketext FROM joke');

    var_dump($result);
    echo mysqli_error();
    ini_set('log_errors',1);

    ?>

    ======================================================
    The result is :-

    object(mysqli_result)#2 (0) { }
    Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\deletejoke\index.php on line 23

    so that worked ok - right ?

  10. #35
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    What is the error that is given? You need to provide $link to mysqli_error as well, for that to show you.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #36
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry - I have to admit I'm new to this and struggling a little.....please bare with me.....

    I've amended the line

    echo mysqli_error();

    to
    echo mysqli_error($link);

    and now get the following

    object(mysqli_result)#2 (0) { }

  12. #37
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by mingkwong View Post
    I've amended the line

    echo mysqli_error();

    to
    echo mysqli_error($link);
    God, just remember that all procedural mysqli_error commands need to have $link passed to them.

    Quote Originally Posted by mingkwong View Post
    and now get the following

    object(mysqli_result)#2 (0) { }
    Good, that's showing that the mysqli_result statement from before generated no errors.

    What do you get when you echo mysqli_num_rows($result);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  13. #38
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh - this is looking good - i believe this is telling me i got my four rows....

    object(mysqli_result)#2 (0) { } 4

    mysql> select count(*) from joke;
    +----------+
    | count(*) |
    +----------+
    | 4 |
    +----------+
    1 row in set (0.01 sec)

  14. #39
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    So what happens now when you do

    Code php:
    while ($row = mysqli_fetch_array($result)) {
        var_dump($row);
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  15. #40
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it sickens me to tell ya.....

    "Internet Explorer cannot display the webpage"

    code as it stands at the moment....

    <?php
    ini_set('display_errors',1);
    error_reporting(E_ALL);

    $link = mysqli_connect('localhost', 'root', 'my_password');
    if (!mysqli_set_charset($link, 'utf8'))
    {
    $output = 'Unable to set database connection encoding.';
    include 'output.html.php';
    exit();
    }

    if (!mysqli_select_db($link, 'joke_db'))
    {
    $error = 'Unable to locate the joke database.';
    include 'error.html.php';
    exit();
    }

    $result = mysqli_query($link,'SELECT id, joketext FROM joke');

    var_dump($result);
    echo mysqli_error($link);
    echo mysqli_num_rows($result);

    while ($row = mysqli_fetch_array($result)) {
    var_dump($row);
    }

    ini_set('log_errors',1);

    ?>

  16. #41
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by mingkwong View Post
    it sickens me to tell ya.....

    "Internet Explorer cannot display the webpage"
    While we're trying to understand this issue, what happend when you tell the php code to finish after echoing the first row?

    Code php:
    while ($row = mysqli_fetch_array($result)) {
        var_dump($row);
        die();
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  17. #42
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    What does the php error log show with the more recent code runs.

    Also, what is the output_buffering set to in php.ini? If it's on and a php error occurs, that can cause IE to show the "cannot display" error message.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #43
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $result = mysqli_query($link,'SELECT id, joketext FROM joke');

    var_dump($result);
    echo mysqli_error($link);
    echo mysqli_num_rows($result);
    while ($row = mysqli_fetch_array($result)) {
    var_dump($row);
    die();
    }

    once again..... "Internet Explorer cannot display the webpage"

    ==================================================
    This is the apache error log......
    The error log shows :-
    Sun Feb 28 00:47:12 2010] [notice] Parent: child process exited with status 255 -- Restarting.
    httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.2 for ServerName
    [Sun Feb 28 00:47:12 2010] [notice] Apache/2.2.14 (Win32) PHP/5.2.12 configured -- resuming normal operations
    [Sun Feb 28 00:47:12 2010] [notice] Server built: Sep 28 2009 22:41:08
    [Sun Feb 28 00:47:12 2010] [notice] Parent: Created child process 1388
    httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.2 for ServerName
    httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.2 for ServerName
    [Sun Feb 28 00:47:12 2010] [notice] Child 1388: Child process is running
    [Sun Feb 28 00:47:12 2010] [notice] Child 1388: Acquired the start mutex.
    [Sun Feb 28 00:47:12 2010] [notice] Child 1388: Starting 64 worker threads.
    [Sun Feb 28 00:47:12 2010] [notice] Child 1388: Starting thread to listen on port 80.

    Sorry - can see where to find the php error log....

    in the php file :-
    output_buffering = Off

  19. #44
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,998
    Mentioned
    100 Post(s)
    Tagged
    0 Thread(s)
    To find your php error log, search the server the server for a file called php_error.log
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  20. #45
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    It seems that the php request is crashing apache.

    There seems to be a fix for this on window systems. Could you investigate updating libmysql.dll as mentioned in this post:
    http://www.apachefriends.org/f/viewt...p?f=16&t=32617

    Edit:

    Copying this file is also mentioned in the book's errata page:
    http://www.sitepoint.com/books/phpmysql1/errata.php
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  21. #46
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SpacePhoenix
    ==========
    I have searched all drives and cannot find this file anywhere....

    pmw57
    =====
    I tried the update (libmysql.dll) .....no joy.

    Thank you for Kevin's update....

    ==================================================
    p.12 Installing PHP
    Although this book provides download and installation instructions for PHP 5.2, the newly-released (at the time of this writing) PHP 5.3 includes some new download options that arenít covered in the book.

    There are four different versions of PHP 5.3. for Windows: VC6 Non Thread Safe, VC6 Thread Safe, VC9 Non Thread Safe, and VC9 Thread Safe. Talk about confusing!

    First of all, you definitely want a Thread Safe version of PHP. The Non Thread Safe versions are not suitable for use as a plugin for Apache.

    Secondly, assuming you will install (or have already installed) a version of the Apache HTTP Server from httpd.apache.org (see page 13), you will need the VC6 version of PHP.

    In short, to follow the instructions in this book, you need the VC6 Thread Safe version of PHP 5.3 for Windows.
    ===================================================

    the time here in blighty is approaching 2am. I'm shot. i need to get some sleep and i can't face the thought of a new install at this time in the morning.
    I really do need to get this stuff working because I'm committed to it for work reasons...

    Thank you for this link.

    I will download and install the latest versions tomorrow and see what happens.....will def let you know....

  22. #47
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,998
    Mentioned
    100 Post(s)
    Tagged
    0 Thread(s)
    Did you restart Apache after making the update?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  23. #48
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok - have some good news.
    the good news is - at long last - i can delete a joke and pull more than a single column from mysql. Excellent !

    I downloaded the lastest verion of php (5.3.1) and stuck it on my laptop
    The laptop is running Vista and the system information tells me system type : 32-bit operating system.

    pulled up my web browser and everything ran - just as it should.

    The machine that I've been using up til now is a pc running 7. system info tells me that it's a 64 bit operating system.

    When I tried to install the new "working version" - (i.e. this mornings download that works on the laptop) on the pc - it had all sorts of problems and wouldn't connect to mysql.

    At this moment in time - I'm happy as I have a full working system on the laptop and I can crack on with my learning. Getting everything working on the pc can be next week's problem.

    Guys - a big thank you to everyone who has helped and advised. I've learnt alot about debugging and resolving issues.

    .............perhaps the old vista laptop ain't so bad after all !


Bookmarks

Posting Permissions

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