Public feed #531324

Stuff

public php v1 · immutable
Raw Edit
·published 2007-06-02 13:16 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head>  <title> </title> </head> <body>	<?php		error_reporting('E_ALL');		function db_connect()		{			require("config.php");			$conn = mysql_connect($hostname,$username,$password);			if ($conn)					return (mysql_select_db("mydb")) ? true : false;			else					echo "Please edit config.php<br />No connection could be made to the database.<br /><br /><span style=\"font-weight:bold;\">ERROR:</span> ".mysql_error(); exit;		}		function create_db()		{			echo "Could not locate the database. attempting to create it.";			$sql_file = "mysql.sql";			if (file_exists($sql_file))			{				$fh = fopen($sql_file,"r");				$sql = fread( $fh, filesize($sql_file) );								$result = mysql_query($sql);				if (mysql_affected_rows() != 0)				{					echo "<br /><h3>Database created sucessfully. please click <a href=\"".$_SERVER['PHP_SELF']."\">here</a> to continue.</h3>";					?>					<div style="position:relative;">						<div style="border:1px solid black;text-align:center;font-size:large;color:black;margin:-10px 0 0 60px;position:absolute;width:75px;background-color:white;">							<p style="padding:0px;margin:0px;">SQL</p>						</div>						<div style="height:250px; width:800px; overflow:auto; margin:30px; border:1px solid black;">							<?=nl2br($sql);?>						</div>					</div>					<?				}				else				{					echo "<br /><h3>Database could not be created. Please check the your permissions and try again or execture mydb.sql manually.</h3>";				}			}			else			{				echo "<br /><h3>could not locate mysql.sql. please be sure that it is in the same directory as this script if you want it to create itself.";                                echo "<br />or you can manually execute it through the mysql console if you do not wish to automate the creation process.</h3>"; exit;			}		}		if (db_connect())			echo "everything is fine.";		else			create_db();			?> </body></html>