PHP klaidos pranesimas. As nesuprantu paprasto dalyko.

Skelbti atsakymą
Žinutė
Autorius
Vartotojo avataras
Zebda
rašytojas profesionalas
rašytojas profesionalas
Pranešimai: 359
Užsiregistravo: 2004 06 08 18:55
Miestas: Kaunas
Susisiekti:

PHP klaidos pranesimas. As nesuprantu paprasto dalyko.

#1 Standartinė Zebda » 2005 12 07 23:19

DUOMENU BAZE.

Kodas: Pasirinkti visus

<html>
<head>
<title>Create Database</title>
</head>
<body>
<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "contacts";
$link = mysql_connect ($host, $user, $password);
$query = "CREATE DATABASE $database";
if (mysql_query($query,$link)){
 	print ("<h3>The database, $database, was successfully created!</h3>");
} else {
 	print ("<h3>The $database database could not be created!</h3>");
} 
mysql_close ($link);
?>
</body>
</html>
... rezultatas - The database, contacts, was successfully created!

LENTELE

Kodas: Pasirinkti visus

<html>
<head>
<title>Creating a Table</title>
</head>
<body>
<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "contacts";
$table = "contact";
$link = mysql_connect ($host, $user, $password);
$query = "CREATE TABLE $table(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, firstname TEXT, lastname TEXT, address TEXT, city TEXT, state TEXT, zip TEXT, phone TEXT, email TEXT, preferred TEXT)";
mysql_select_db ($database, $link);
if (mysql_query ($query, $link)) {
 	print ("<h3>The query -<h3><p>$query</p><h3>was successful</h3>");
}else {
 	print ("<h3>The query -<p>$query</p><h3>failed.</h3>");
} 
mysql_close ($link);
?>
</body>
</html>
... rezultatas - The query -

CREATE TABLE contact(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, firstname TEXT, lastname TEXT, address TEXT, city TEXT, state TEXT, zip TEXT, phone TEXT, email TEXT, preferred TEXT)
was successful


DUOMENU ITERPIMO SKRIPTAS

Kodas: Pasirinkti visus

<html>
<head>
<title>Contact Form</title>
<style type="text/css">
table {
	border: 1px solid #000000;
	border-bottom: none;
	width: 300px;
	background-color: #CCCCCC;
	}
table td{
	padding: 5px 10px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
	border-bottom: 1px solid #000000;
	}
</style>
</head>
<body>
<?php
	foreach (array_keys($_POST) as $key) {$$key=$_POST[$key];}
	if($post){
		$host = "localhost";
		$user = "root";
		$password = "";
		$database = "contacts";
		$table = "contact";
		$link = mysql_connect ($host, $user, $password);
		$preferred = implode(', ',$preferred);
		$query = "INSERT INTO $table VALUES(null,'$firstname','$lastname','$address','$city','$state','$zip','$phone','$email','$preferred')";
		mysql_select_db ($database, $link);
		if (mysql_query ($query, $link)) {
 			print ("<h3>The query -<h3><p>$query</p><h3>was successful</h3>");
			print ("<p><a href='$PHP_SELF'>Add Another?</a></p>");
			print ("<p><a href='select.php'>View All?</a></p>");
		}else {
 			print ("<h3>The query -<p>$query</p><h3>failed.</h3>");
		} 
		mysql_close ($link);
	print("<h3>Your information has been added to the database. <br />Thank you.</h3><p>Here is what you submitted:</p>");
	print("<strong>First Name:</strong> $firstname<br />");
	print("<strong>Last Name:</strong> $lastname<br />");
	print("<strong>Address:</strong> $address<br />");
	print("<strong>City:</strong> $city<br />");
	print("<strong>State:</strong> $state<br />");
	print("<strong>Zip:</strong> $zip<br />");
	print("<strong>Phone:</strong> $phone<br />");
	print("<strong>E-mail:</strong> $email<br />");
	print("<strong>How to contact:</strong> $preferred<br />");
	}else{
	print("
<form action='$PHP_SELF' method='post'>
<table cellspacing='0'>
<tr><td>First Name:</td><td><input type='text' id='firstname' name='firstname' /></td></tr>
<tr><td>Last Name:</td><td><input type='text' id='lastname' name='lastname' /></td></tr>
<tr><td>Address:</td><td><input type='text' id='address' name='address' /></td></tr>
<tr><td>City:</td><td><input type='text' id='city' name='city' /></td></tr>
<tr><td>State:</td><td><input type='text' id='state' name='state' /></td></tr>
<tr><td>Zip Code:</td><td><input type='text' id='zip' name='zip' /></td></tr>
<tr><td>Phone:</td><td><input type='text' id='phone' name='phone' /></td></tr>
<tr><td>E-Mail:</td><td><input type='text' id='email' name='email' /></td></tr>
<tr><td colspan='2'><p>How would you like to be contacted?</p>
Postal Mail: <input type='checkbox' id='preferred[]' name='preferred[]' value='mail' />
Phone: <input type='checkbox' id='preferred[]' name='preferred[]' value='phone' />
E-mail: <input type='checkbox' id='preferred[]' name='preferred[]' value='email' /><br />
</td></tr>
<tr><td>&nbsp;</td><td><input type='submit' id='submit' name='submit' value='Send' /><input type='reset' id='reset' name='reset' value='Erase' /><input type='hidden' name='post' id='post' value='1' /></td></tr>
</table>
</form>");
}
?>
</body>
</html>
... rezultatas
Lentele matosi, taciau apacioje meta klaida kurios as nesuprantu. Suprantu tik tiek kad tose eilutese kazkas yra negerai, taciau kas nesuprantu. HELP!!!
Notice: Undefined variable: post in c:\program files\easyphp1-8\www\poligonas\php\insert.php on line 20

Notice: Undefined variable: PHP_SELF in c:\program files\easyphp1-8\www\poligonas\php\insert.php on line 50
Gyvenimas yra gražus ! ! !

Vartotojo avataras
Laurynas
administratorius
administratorius
Pranešimai: 2011
Užsiregistravo: 2001 12 06 09:51
Miestas: Vilnius

#2 Standartinė Laurynas » 2005 12 08 14:02

Panasu kad cia viskas gerai. Nors pabandyk laikinai pakeisti:

Kodas: Pasirinkti visus

<form action='$PHP_SELF' method='post'> 
i
<form method='post'>
Cia kadangi lokaliam serveryje, tai tau reikia paziureti php konfige register_globals reiksmes:

http://lt.php.net/manual/en/language.va ... efined.php

Ramex
naujokas
naujokas
Pranešimai: 17
Užsiregistravo: 2006 04 24 15:25

klaida

#3 Standartinė Ramex » 2006 04 24 16:19

siaip ant nauju php versiju tokio dalyko kaip $PHP_SELF nebera. vietoj to reikia rasyti $_SERVER['PHP_SELF'] gal pades...

Skelbti atsakymą

Grįžti į

Dabar prisijungę

Vartotojai naršantys šį forumą: 1 ir 0 svečias(ių)