Jump to content

[SOLVED] PHP Mysql Issues on Hostmonster Please Help


yellowzm

Recommended Posts

I Just signed up for hosting at hostmomster and then I uploaded my site, imported my db from the old site on yahoo, then changed all the info in my script to match my new password, db name, etc. After doing that I tried to view the page and all 3 scripts display the following errors.

 

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/teambrav/public_html/home.php on line 138

 

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/teambrav/public_html/home.php on line 164

 

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/teambrav/public_html/home.php on line 183

 

Bill from tech support said to me "you are declaring a argument for a mysql query. the argument is $result for some reason it does not apper to be properly declared"

If he is correct how do I fix it? The exact same script works perfectly on our test site that I host at Yahoo so I am confused and I am really new to php and mysql.

 

http://teambraves.org/home.php is where you can see the page for yourself.

 

all 3 are identical but take data from different tables

And here is the code:

 

<?php 
   mysql_connect("localhost","dbname","dbpass"); 
   mysql_select_db("dbname"); 
   $query ="SELECT newstitle, newsbody, newssub, postby,"; 
   $query.=" DATE_FORMAT(postdate, '%M %d, %Y') AS date"; 
   $query.=" FROM news ORDER BY postdate DESC LIMIT 9"; 
   $result=mysql_query($query); 
   while (list($newstitle,$newsbody,$newssub,$postby,$postdate,) = 
    mysql_fetch_row($result)) { 
       echo "<dt><b><h1>$newstitle </h1></b></dt>"; 
       echo "<dd><b><h2>$newssub </h2></b></dd>"; 
       echo "<dd><h4><b>Posted By: $postby;($postdate)</b></h4></dd>"; 
       echo "<dd> </dd>"; 
       echo "<dd>$newsbody</dd>"; 
   } 
?>

 

Thanks for the help in advance.

Your query is failing this is why you're retrieving the above error. Change

 $result=mysql_query($query); 

to

 $result=mysql_query($query) or die('MySQL Error: ' . mysql_error() . '<br />Query: '.htmlentities($query,ENT_QUOTES)); 

Now an error message will be displayed if your queries are failing

I changed the code as suggested and this is the error I get.

 

MySQL Error: No database selected

Query: SELECT eventtitle, eventbody, eventtime, eventsub, weighin, directions, DATE_FORMAT(eventdate, '%M %d, %Y') AS date FROM events WHERE eventdate >= '2009-02-15' ORDER BY eventdate ASC LIMIT 100

 

Thanks for the help I do appreciate it

Ok your code is not selecting a database properly

 

Change these lines

mysql_connect("localhost","dbname","dbpass"); 
  mysql_select_db("dbname"); 

to these

mysql_connect("localhost","dbname","dbpass") or die('Unable to connect to mysql server: '.mysql_error()); 
  mysql_select_db("dbname")or die('Unable to select database: '.mysql_error()); ; 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.