+ Reply to Thread
Results 1 to 8 of 8

Thread: PHP and MYSQL

  1. #1
    pranav95 is offline x10Hosting Member pranav95 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    44

    PHP and MYSQL

    I try to run a mysql query in my website using php but I get the error mentioned below:-

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

  2. #2
    as4s1n's Avatar
    as4s1n is offline x10 Sophmore as4s1n is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Washington State
    Posts
    174

    Re: PHP and MYSQL

    That usually means that there was an error with your query. However, no one can help you unless you post the code with this error.
    There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.

  3. #3
    essellar's Avatar
    essellar is offline Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,153

    Re: PHP and MYSQL

    The error message means what it says, which means that your problem lies in the query or the connection -- or you could simply have a typo in your code. You'd need to post code in order to get any more help.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  4. #4
    varunaroli is offline x10Hosting Member varunaroli is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    4

    Re: PHP and MYSQL

    plz use mysql error () command.

    Eg:

    <?php

    $query="select * from tble";

    mysql_query($query) or die(mysql_error());

    ?>

    it will help you to find out errors.
    Last edited by varunaroli; 06-06-2010 at 03:20 AM.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP and MYSQL

    Just make sure you don't use or die or output mysql_error() for non-admin users in production code.
    Last edited by misson; 06-08-2010 at 12:31 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  6. #6
    jedaivokters is offline x10Hosting Member jedaivokters is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    10

    Re: PHP and MYSQL

    try this out http://w3schools.com/php/php_mysql_intro.asp . It has good tutorials
    Last edited by jedaivokters; 06-09-2010 at 07:18 AM.

  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP and MYSQL

    W3Schools is outdated, inaccurate and incomplete, and that's not just my opinion.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  8. #8
    sanji41 is offline x10Hosting Member sanji41 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    1

    Re: PHP and MYSQL

    hi im connecting my db on x10hosting which uses cpanel however i can't seem to connect it, i dont know what to put on username and localhost and the dbname..please help!

+ Reply to Thread

Similar Threads

  1. Replies: 2
    Last Post: 02-01-2010, 05:45 AM
  2. mySQL error - argument is not a valid MySQL result resource
    By Awesomexr in forum Programming Help
    Replies: 3
    Last Post: 12-20-2009, 04:12 PM
  3. Replies: 3
    Last Post: 02-14-2008, 01:38 PM
  4. Replies: 2
    Last Post: 12-17-2007, 03:00 AM
  5. Replies: 2
    Last Post: 11-20-2007, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers