Results 1 to 7 of 7
  1. #1
    Join Date
    May 2008

    Red face Unanswered: MySQL error - need help asap

    Database mysql error - Need help asap

    -------------------------------------------------------------------------------- and

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kenburns/public_html/new.php on line 104

    Error messages on those lines are:

    Line 104 on NEW.php


    and same exact error on 103 on used.php

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    you're going to have to tell us the actual mysql error

    "not a valid MySQL result resource" is a php error

    showing the actual sql for the query would be a good idea, too | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2008
    I am clueless to all this I have no idea what to do or what happened. This was something that was transferred over from another server - I had it all transferred and working for more than a year now - could a user that entered info into the database mess it up?? I'm willing to give access.

  4. #4
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    when did it go wrong?
    has it worked on the new server?
    has the db server chanegd as well as the web server, if so have you changed the data server hostname,userid & password.
    if it has run fine on the new server then I'd expect you have a corrupt script
    if it has't then I'd expect the proble, to be that you haven't localised the script for the new server(s).

    so because you haven't supplied the details n the script, ie the section that is going wrong. usually contributors hee wold expect to see the few lines (NOT the whole script) of code leading up to the error... you don't need to (and shouldn't) procide serverid(hostname), userid & passwords.. thats a security breach which could lead to your system being compromised, nor should you provide access to your server through ftp or any other mechanism.. thats a security breach.

    I'd suggest you put an OR DIE statement after each mysql operation and see where the script is actually dieing. becuase of the nature of PHP its quite possibel tht the error you are seeing is not actaully on the line nmber reported.. the fault is upstream of that.

    the syntax I use for error handling is
    or die($Module,"E:10350 - Failed to open cnn: ".mysql_errno().": ".mysql_error());

    where $Module tells me which script is reporting the error
    the E:xxxxx is an error number and message generated by me and specific to the error.... eg this error message tells me I was attempting to open a conection
    the mysql_errno() & mysql_error() repeat the error message from MySQL
    if the MySQL command is a SQL select or update then I also repeat the SQL that failed to check that the SQL that failed is what Im expecting to have sent.

    so over to you
    check the hostname, userid & password first.. put an or die after the opening of the connection
    put an or die after the selection of the db
    put an or die after each and every select statement

    One word of caution though, although this site does help beginners (we all have to start somewhere, its not a mechanism for you to learn form scratch PHP / MySQL development). Its unlikely you will find someone able to hold your hand through the whole process.. you will have to learn by doing. try W3 schools. .they are a pretty good learnign resource, the PHP.NET site is a pretty good reference (although as useful for beginners, its great for those who know what the want to do but don't know the minutae of PHP). And don't overestimate the value of a good PHP book (try a 'bible' book form Wiley)
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    May 2008
    Well, if this helps and I'm sorry - I just don't have a clue with all this... and now when the user tries to login, this error comes up also:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kenburns/public_html/back/adrec.php on line 7
    and that error is underneath this one:

    $qu="select * from cars where tipo=1";
    <th colspan="2" align="left" valign="top" scope="col">
    <span class="bodyText">Model: <strong>'.$row['model'].'</strong><br />
    Year: '.$row['year'].' <br />
    <a href="deta1.php?id='.$row['id'].'" target="_blank">Details</a></span></th>
    <th height="20" align="left" valign="top" scope="col"></th>
    <th align="left" valign="top" class="bodyText" scope="col"></th>

    <link rel="stylesheet" href="cms.css">
    <?print"<center><table width=800 height=550 border=1 bordercolor=black bgcolor=\"#C5812D\"><tr><td valign=top>";
    $ad="select * from pass";
    if(($rand['user']!=$_SESSION['user'][0])||($rand['pass']!=$_SESSION['pass'][0]))print"<h3>Date de conectare incorecte!</h3>";

  6. #6
    Join Date
    Jun 2007
    Not sure if these things make a difference but I thought I'd chuck my 2c in as well:
    • Usually the code would start
      rather than
    • Is there a file called conect.php in that directory or should it be connect.php?
    • If you run "select * from cars where tipo=1" on the database do you get fields returned called tipo, model, year and id?
    • The field tipo=1 looks a bit suspicious to me - I just can't think what it might do.
    • Try looking up about indenting of code - it makes code so much easier to read
    • As healdem says you should have code to catch the errors so change
      $rez=mysql_query($qu) or die( "Error in SQL: " . $qu . mysql_error() );
    Last edited by mike_bike_kite; 05-20-08 at 18:48.

  7. #7
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    what is the history of this script?
    has it worked somewhere before, and now its not working? theres confidence that the basic script logic an processes are OK, but its just a matter of fixing what ever has changed since it last worked...
    has it never worked?
    ...the problem could be anywhere...

    to me the error message you are reporting suggests the fault is in either the connection or selection of the database... both of which Im guessing are in "connect.php"

    placing an or die on all 3 MySQL functions is a first step
    so look at connect.php
    and place an or die construct after the mysql_connect, mysql_select_db and
    mysql_query functions
    Form whatr you have said so far I'm pretty certain your error will turn out to be on either the connect or selectdb statements.

    either servername userid and password are invalid (or all 3!), or the database name is invalid.

    FWIW this is an approximation of the code I use in one script. normally errors ar sent to a single error handler which decides how to inform the user of the error, which is diferent depending on where the script is running....more information is displayed n the screen in development and less (well no detail) in the live version

    $cnn=@mysql_connect(HOST,UID1,PWD1) or die($Module.":"E:1035 - Failed to open cnn ".mysql_errno().": ".mysql_error());
    $dbr=@mysql_select_db(DBN,$cnn) or die ($Module." E:1036 - Failed to open db: DBN ".mysql_errno().": ".mysql_error());
    $strSQL = "select LangName, ResLocation from Languages where LangID=$pLID;";
    $ResultSet=@mysql_query($strSQL,$cnn) or die ($Module." E:1037 - Failed to open rs ".mysql_errno().": ".mysql_error()." SQL is:strSQL");
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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