Jump to content

Is it me or my host...


alexsmith2709

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.