Jump to content

Very basic problem with php


Recommended Posts

I've just installed apache, mysql and php in windows. Ive got the apache server running and the mysql server running and i assume the php is working.

Ive set my intranet as a html/css based page and one of the links on that page is a link to

 

text.php - when this script contains something simple like

 

<?php

echo 'this is a test';

?>

then when i click on the link in my intranet and i get the result output onto the new webpage.

 

However if i add something more to it like

 



<?php

$dbhost = 'Brnew.home:3306';
$dbuser= 'root';
$dbpass= 'mypass';
$dbname = 'intranet';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
	    ('Error Connecting to mysql');


mysql_select_db($dbname);

echo 'database opened';

mysql_select_db('intranet') or die('Cannot select database'); 

$query = 'CREATE TABLE contacts( '.
         'cid INT NOT NULL AUTO_INCREMENT, '.
         'cname VARCHAR(20) NOT NULL, '.
         'cemail VARCHAR(50) NOT NULL, '.
         'cnumber VARCHAR(30) NOT NULL, '.
         'cinfo TEXT NOT NULL, '.
         'PRIMARY KEY(cid))';

$result = mysql_query($query);


mysql_close($conn);



?>

 

 

Then when i click the link in my intranet it dosent display the page, i get an error saying this page cannot be displayed

Link to comment
https://forums.phpfreaks.com/topic/112262-very-basic-problem-with-php/
Share on other sites

There is most likely an error with that php code. If you are using internet explorer go to

tools >> internet options >> click on the advanced tab >> under the browsing tab uncheck the box "show friendly http error messages"

and then look at the page...it will show you the php error and not "page cannot be displayed"

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.