If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL error - need help asap

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-08, 20:45
missimc missimc is offline
Registered User
 
Join Date: May 2008
Posts: 3
Red face MySQL error - need help asap

Database mysql error - Need help asap

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

http://www.kenburnsinc.com/new.php and
http://www.kenburnsinc.com/used.php

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

while($row=mysql_fetch_array($rez))

and same exact error on 103 on used.php
Reply With Quote
  #2 (permalink)  
Old 05-19-08, 21:25
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-19-08, 21:32
missimc missimc is offline
Registered User
 
Join Date: May 2008
Posts: 3
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.
Reply With Quote
  #4 (permalink)  
Old 05-20-08, 03:25
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 05-20-08, 18:18
missimc missimc is offline
Registered User
 
Join Date: May 2008
Posts: 3
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:

<?include("conect.php");
$qu="select * from cars where tipo=1";
$rez=mysql_query($qu);
while($row=mysql_fetch_array($rez))
print'<tr>
<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>
</tr>
<tr>
<th height="20" align="left" valign="top" scope="col"></th>
<th align="left" valign="top" class="bodyText" scope="col"></th>
</tr>';
?>



-----------
?session_start();?>
<link rel="stylesheet" href="cms.css">
<?print"<center><table width=800 height=550 border=1 bordercolor=black bgcolor=\"#C5812D\"><tr><td valign=top>";
include("../conect.php");
$ad="select * from pass";
$re=mysql_query($ad);
$rand=mysql_fetch_array($re);
if(($rand['user']!=$_SESSION['user'][0])||($rand['pass']!=$_SESSION['pass'][0]))print"<h3>Date de conectare incorecte!</h3>";
else{
include("meniu.php");print"<br><br><br><center>";
if(isset($_POST['add']))
Reply With Quote
  #6 (permalink)  
Old 05-20-08, 18:44
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Not sure if these things make a difference but I thought I'd chuck my 2c in as well:
  • Usually the code would start
    Code:
    <?
    include("conect.php");
    rather than
    Code:
    <?include("conect.php");
  • 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
    Code:
    $rez=mysql_query($qu);
    to
    Code:
    $rez=mysql_query($qu) or die( "Error in SQL: " . $qu . mysql_error() );
Mike

Last edited by mike_bike_kite; 05-20-08 at 18:48.
Reply With Quote
  #7 (permalink)  
Old 05-21-08, 02:01
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
what is the history of this script?
has it worked somewhere before, and now its not working?
...ie 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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On