Hi everybody,
I'm new in PHP coding a I want to wrote php script, which find some data in database. But it doesn't work.When I submit form to search, it's write an error:
Connection not avaliable!
Error 403!
localhost
05/27/09 22:33:46
Apache/2.2.11 (Win32) PHP/5.2.8

Could somebody help me?

<?php
error_reporting (E_ALL ^ E_NOTICE);
ini_set("display_errors",1);
include('incl/str.php');
require_once('incl/header.php');
$title = $str["student_search"];
?>

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN''http://www.w3.org/TR/html4/strict.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php print('EDUKID - $title'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel='stylesheet' type='text/css' href='../css/edukid_default.css'>
<STYLE>
#but1 {width: 200px;}
</STYLE>
</head>
<body>
	<IMG id="lupa" src="../img/lupa.png" alt="lupa">
   	<H1 class="student_search_nadpis">Vyhladavanie ziakov</H1>
		<form method="post" action='".$_SERVER["PHP_SELF"]."?action=hladaj'>
		<table>
		<tr>
	<th class="odstavec1">Meno: </th>
	<th class="odstavec1">Rocnik: </th>
	<th class="odstavec1">Predmet: </th>
	<th class="odstavec1">Zoznam vsetkych ziakov: </th>
		</tr>
		<tr>
			<td class="odstavec2" width='6' ><input type="text" name="meno"></td>
			<td class="odstavec2" width='6' nowrap="nowrap" ><select name="rocnik"><option value="1">Prvy</option>
														<option value="2">Druhy</option>
														<option value="3">Treti</option>
														<option value="4">Stvrty</option></select><br /></td>
			<td class="odstavec2" width='6' nowrap="nowrap"><select name="predmet"><option value="Matematika">Matematika</option></select></td>
		</tr>
		</table>
		<center><input class="hladaj" id="but1" type="submit" value="Hladaj"></center>
		<hr />
			<h3 align="center">Vysledky Vyhladavania</h3>
		<table>
		<tr>
			<th class="odstavec3">Meno: </th>
			<th class="odstavec3">Predmet: </th>
			<th class="odstavec3">Rocnik: </th>
		</tr>
		<tr>
			<td class="odstavec2" width='6' nowrap="nowrap"><input type="checkbox" value="ziak" name="ziak"></td>
		</tr>
		</table>
		<hr />
			<h3 align="center">Akcie</h3>
		<table>
		<tr>
			<td class="odstavec4" >Zapisat predmet: </td>
			<td class="odstavec4" width='6' nowrap="nowrap" ><select name="predmet"><option value="matematika">Matematika</option></select>
		</tr>
		<tr>
			<td class="odstavec4" >Odpisat predmet: </td>
			<td class="odstavec4" width='6' nowrap="nowrap" ><select name="predmet"><option value="matematika">Matematika</option></select>
		</tr>
		<tr><td><input class="hladaj" id="but1" type="submit" value="Presun do dalsieho rocnika"></td></tr>
		<tr><td><input class="hladaj" id="but1" type="submit" value="Ukoncit studium"></td></tr>
		</table>
		</form>
		<?php
		if ($_GET['action']=='hladaj'){
			$meno = $_POST["meno"];
			//$rocnik=$_POST[["rocnik"];
			//$predmet=$_POST["predmet"];
			$query="SELECT * usr_name FROM usr WHERE meno = '" . $meno . "'";
			$result=mysql_query($query) or die ("Chyba mysql prikazu");
			if(mysql_num_rows($result) == null){
				//header("Location:index.php");
				exit;
				}
				$line=mysql_fetch_array($result);
				echo $result['name'];
				echo "<br>";
		}
		@mysql_close($connect);
		?>
		
</body>
</html>

Recommended Answers

All 7 Replies

Your mysql_connect call isn't in that code but I can tell that you don't have a mysql server setup on localhost.

ShawnCplus maybe correct unless the mysql connect and database details are stored in the include or required files below:

include('incl/str.php');
require_once('incl/header.php');

ShawnCplus maybe correct unless the mysql connect and database details are stored in the include or required files below:

include('incl/str.php');
require_once('incl/header.php');

Yes, you're right...mysql connect and databse details are stored in the include files in this form:

<?php
if (!isset($database_connection)){
   mysql_connect("localhost", "igorlov", "edukidDB232")
      or die("Problems with connection!");
   mysql_select_db("igorlov_edukid")
      or die("Problems with database selection!");   
}
$database_connection = true;
?>

I would remove your password asap so people are not able to see it mysqlconnect( root, username, password). Minus that it looks like it is fine. First check if all your database name are equal to each other and same as your root. Ill come back and check later when I have more time to your response.

dsadasdadasdadas

Yes, you're right...mysql connect and databse details are stored in the include files in this form:
<?php
if (!isset($database_connection)){
mysql_connect("localhost", "user_name", "password")
or die("Problems with connection!");
mysql_select_db("database_name")
or die("Problems with database selection!");
}
$database_connection = true;
?>

what is this dasasadadadadda stuff? Are you just trying to bump your post with no meaningful information, or ask a question? I told you in my first post, you don't have a mysql server started on localhost, so start one or point to one.

I think ShawnCplus said that you dont have mysql installed on the server?
Do you?
You can check via apache I think but it should be in your startup programs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.