alexsmith2709 Posted January 14, 2011 Share Posted January 14, 2011 I am creating a news updates thing for my website and i have managed to get it working on my home PC (im using XAMPP) but when i upload to my webhost it doesnt appear to work. I am wondering if it is just my host or whether i have done something wrong and by chance it works on my home PC. Here is my code: <?php include("includes.php"); doConnect(); $get_news = "SELECT title, text, DATE_FORMAT(datetime, '%e %b %Y at %T') AS datetime FROM newsfeed ORDER BY datetime DESC"; $result= mysqli_query($mysqli, $get_news) or die(mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { echo '<strong>'. $row['title'] .' </strong><br>'. $row['text'] .'<br>'. $row['datetime'] .'<br><br>';} ?> My includes file is: <?php function doConnect() { global $mysqli; //connect to server and select database $mysqli = mysqli_connect("localhost", "user", "password", "dbname"); //if connection fails, stop script execution if (mysqli_connect_errno()) { printf("Connection failed: %s\n", mysqli_connect_error()); exit(); } } ?> I think im right in saying it connects properly because i do not see an error. what i get is: '. $row['title'] .' '. $row['text'] .' '. $row['datetime'] .' ';} ?> Im new to PHP (incase you hadnt guessed!) so not really sure whats happening. On my home PC i have PHP Version 5.3.1 and on my webhost its 5.2.14. Home PC mySQL version 5.1.41 and on webhost its 5.0.91-community. Could this be the reason? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/ Share on other sites More sharing options...
BlueSkyIS Posted January 14, 2011 Share Posted January 14, 2011 it appears the PHP is not being parsed by the web server. does the file name end with .php? is the remote server Windows or other (linux/unix/mac)? Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/#findComment-1159384 Share on other sites More sharing options...
alexsmith2709 Posted January 14, 2011 Author Share Posted January 14, 2011 Wow quick reply. Thanks. Sorry forgot to mention this is in a .html file. I've included PHP in a HTML file before but could this be the reason? That would be the only thing thats changed from my local setup. That didnt cross my mind! changing to .php appears to work. thanks very much Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/#findComment-1159389 Share on other sites More sharing options...
BlueSkyIS Posted January 14, 2011 Share Posted January 14, 2011 this is what i use in the top of .htaccess file to cause HTML, .htm and .shtml files to be parsed as PHP: AddType application/x-httpd-php .html .htm .shtml I have also seen variations on this, most often specifying php4 or php5 as follows: AddType application/x-httpd-php5 .html .htm .shtml Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/#findComment-1159396 Share on other sites More sharing options...
alexsmith2709 Posted January 14, 2011 Author Share Posted January 14, 2011 Thanks very much. will try those, but for now my host has decided to break! Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/#findComment-1159397 Share on other sites More sharing options...
Maq Posted January 14, 2011 Share Posted January 14, 2011 Thanks very much. will try those, but for now my host has decided to break! Sounds like you need a new host ;/ Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/#findComment-1159481 Share on other sites More sharing options...
phpfreak Posted January 15, 2011 Share Posted January 15, 2011 Webhost Freaks - owned by PHPFreaks.com can assist you if needed: http://www.WebHostFreaks.com - all hosting sales go in direct support of PHPFreaks and our continued operation of this site. We can parse .html files as PHP as well. Thanks and Good Luck on your coding adventures. Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/#findComment-1159831 Share on other sites More sharing options...
alexsmith2709 Posted January 15, 2011 Author Share Posted January 15, 2011 Thanks for all your help guys. Much appreciated. Got my host to move me to a different server and now all is well and i have a site functioning as i want....for now! I may well be back soon asking more questions, but will definately stick around reading other topics etc to gain more knowledge. Quote Link to comment https://forums.phpfreaks.com/topic/224435-is-it-me-or-my-host/#findComment-1159837 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.