SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict mh8759's Avatar
    Join Date
    Jun 2000
    Location
    Slovenia, Europe
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been working with PHP and MySql. In fact, i'm learning these two tools using Kevin Yank's tutorial. When I try to run example on page 34(connecting to database and printing entries out in the internet browser) , I get this error out:

    Warning: Supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\Celisvet\baza1.php on line 43

    This is how line 34 looks like:

    while($row = mysql_fetch_array($result)) {
    echo("<p> . $row["JokeText"] . "</p>");
    }

    I suppose there is something wrong with sending variable($result) to the function.
    However, I don't know what is wrong. I suppose it should work, if it is in the tutorial. Is there something wrong with the connection to the database? I'm using PWS with win98.

    There's another issue i hava to ask about. I've never noticed PHP files with .php4 extension. It seems, everyone uses .php3. What's the reason for this(we know that php4 is released)?

    i hope someone can answer my questions
    thank you
    Marko

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi!

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>Warning: Supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\Celisvet\baza1.php on line 43<HR></BLOCKQUOTE>

    This error occurs when you try to use a variable as a MySQL result set (in this case, $result) when it doesn't contain one (usually because the MySQL query failed for some reason).

    To determine why a query has failed, you need to check for an error after issuing the query. If an error is detected, you should then use mysql_errror() to print it out.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>This is how line 34 looks like:

    while($row = mysql_fetch_array($result)) {
    echo("&lt;p&gt; . $row["JokeText"] . "&lt;/p&gt;");
    }
    <HR></BLOCKQUOTE>

    To check for errors, add the following above that line:

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>if (!$result) {
    echo("&lt;p&gt;MySQL error: " . mysql_error());
    exit();
    }[/code]

    When you try your page now, it should print out the MySQL error message telling exactly what went wrong. In all likelihood, there was a syntax error in your query.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>There's another issue i hava to ask about. I've never noticed PHP files with .php4 extension. It seems, everyone uses .php3. What's the reason for this(we know that php4 is released)?<HR></BLOCKQUOTE>

    .php3 was the standard file extension for PHP 3.x. In PHP 4.x, this has changed to .php, but since many PHP sites were created with or are still running PHP 3.x, the filenames are only beginning to change slowly.

    In theory, though, you can name a PHP file anything you want, as long as your Web server is configured to recognize it as a PHP script.



    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!

  3. #3
    SitePoint Addict mh8759's Avatar
    Join Date
    Jun 2000
    Location
    Slovenia, Europe
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i did not find anything wrong with query nor did the PHP script engine reported any errors. the line you wrote was already written in my script because i'm following your articles therefore there should be no mistakes. i really don't know what's wrong...i have mysqld in my Startup folder and mysql works fine too when i try to add or edit data manually from mysql monitor in command prompt.
    as i said, even mysql_error doesn't report anything..i'll keep trying, in the meantime do you have any suggestions?

    marko

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    marko,

    Can you email me baza1.php that you're having problems with? I'd like to have a look at the exact code you're using so that I can find the problem.


    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!


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
  •