yellowzm Posted February 15, 2009 Share Posted February 15, 2009 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. Link to comment https://forums.phpfreaks.com/topic/145290-solved-php-mysql-issues-on-hostmonster-please-help/ Share on other sites More sharing options...
wildteen88 Posted February 15, 2009 Share Posted February 15, 2009 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 Link to comment https://forums.phpfreaks.com/topic/145290-solved-php-mysql-issues-on-hostmonster-please-help/#findComment-762725 Share on other sites More sharing options...
yellowzm Posted February 15, 2009 Author Share Posted February 15, 2009 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 Link to comment https://forums.phpfreaks.com/topic/145290-solved-php-mysql-issues-on-hostmonster-please-help/#findComment-762733 Share on other sites More sharing options...
wildteen88 Posted February 15, 2009 Share Posted February 15, 2009 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()); ; Link to comment https://forums.phpfreaks.com/topic/145290-solved-php-mysql-issues-on-hostmonster-please-help/#findComment-762738 Share on other sites More sharing options...
yellowzm Posted February 16, 2009 Author Share Posted February 16, 2009 Thanks for the help, I managed to get it working again. for some reason it was not working with the user name that I had added. I would not have ever figured it out w/o the code y'all helped me with. Link to comment https://forums.phpfreaks.com/topic/145290-solved-php-mysql-issues-on-hostmonster-please-help/#findComment-763162 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.