PHP Help

Associate
Joined
2 Sep 2007
Posts
2,001
Hi excuse me I'm new to PHP. I have managed to pull some data from a database but for some reason this won't work: -

Code:
<html>
<head>
<title>Test Insert</title>
</head>
<body>
<?php
	$user_name = "myusername";
	$password = "mypassword";
	$database = "mydb";
	$server = "localhost";

	$db_handle = mysql_connect($server, $user_name, $password);
	$db_found = mysql_select_db($database, $db_handle);

	if ($db_found) {

	      //$SQL = "INSERT INTO studentbanlist (moodleid, banreason) VALUES ('5', 'Abusive to other students.')";


       	//$result = mysql_query($SQL);
	//mysql_close($db_handle);
		print "Records added to the database";

	else {
		print "Database NOT Found ";
		mysql_close($db_handle);
	}
?>
</body>
</html>

With or without the lines commented out when I run this code all I see a blank page? :( I know the user_name, etc is fine because I can pull info from the db. Any ideas?
 
Open your php.ini file, and look for the error_reporting like, and change it to:
Code:
error_reporting = E_ALL & E_STRICT
and likewise for the line beginning with display_errors, change to:
Code:
display_errors = On
then restart your webserver.
 
Open your php.ini file, and look for the error_reporting like, and change it to:
Code:
error_reporting = E_ALL & E_STRICT
and likewise for the line beginning with display_errors, change to:
Code:
display_errors = On
then restart your webserver.

Cheers unfortunately I can't restart the webserver.
 
Install php and apache2 locally, and use it run your applications before you upload to the webserver. Many of the problems you are posting about will be easily solved with those options on.
 
Cheers unfortunately I can't restart the webserver.

You can turn it on for individual scripts, stick this at the top of the file:

Code:
<?php 
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

Also, never have display_errors enabled on live hosting, keep it to your development environment.
 
Back
Top Bottom