Undefined index pomoc

1

Undefined index pomoc

offline
  • Pridružio: 17 Avg 2012
  • Poruke: 6

Treba mi pomoc, tek sam pocetnik u PHP programiranju pa me muci jenda greska
kod je pregledan izjedne knige PHP-a ali kod mene nece da radi.
Evo koda

<?php //create short variable names $tireqty = $_POST ['tireqty']; $oilqty = $_POST ['oilqty']; $sparkqty = $_POST ['sparkqty']; ?> <html> <head>    <title>Bob's Auto Parts - Oreder Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php    echo '<p>Order processed at ';    echo date ('H:i:s, jS F Y.');    echo ' Godina';    echo '</p>';    echo '<p>You order is as follows: </p>';    echo $tireqty.' tires<br />';    echo $oilqty.' bootles oil<br />';    echo $sparkqty.' spark plugs<br />'; ?> </body> </html>

A evo i rezultata koda

Notice: Undefined index: tireqty in C:\xampp\htdocs\bob1.php on line 3 Notice: Undefined index: oilqty in C:\xampp\htdocs\bob1.php on line 4 Notice: Undefined index: sparkqty in C:\xampp\htdocs\bob1.php on line 5 Bob's Auto Parts Order Results Order processed at 12:30:53, 17th August 2012. Godina You order is as follows: tires bootles oil spark plugs

Hvala unapred.



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • C# and PHP Developer
  • Pridružio: 16 Feb 2011
  • Poruke: 1625
  • Gde živiš: Pancevo

Nedefinisani index. Googlaj malo


promeni ovo

if (isset($_POST('submint')) {     $tireqty = $_POST ['tireqty'];     $oilqty = $_POST ['oilqty'];     $sparkqty = $_POST ['sparkqty']; }

U Html formi stavi id = sumbint

<imput  type="submit" name = "submit" value = "Posalji" >



offline
  • Pridružio: 17 Avg 2012
  • Poruke: 6

_iKaC ::Nedefinisani index. Googlaj malo


promeni ovo

if (isset($_POST('submint')) {     $tireqty = $_POST ['tireqty'];     $oilqty = $_POST ['oilqty'];     $sparkqty = $_POST ['sparkqty']; }

U Html formi stavi id = sumbint

<imput  type="submit" name = "submit" value = "Posalji" >



Nece opet kada to uradim onda mi izbaci fatal error
<?php //create short variable names if (isset($_POST('submint')) {     $tireqty = $_POST ['tireqty'];     $oilqty = $_POST ['oilqty'];     $sparkqty = $_POST ['sparkqty']; } ?> <html> <imput  type="submit" name = "submit" value = "Posalji" > <head>    <title>Bob's Auto Parts - Oreder Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php    echo '<p>Order processed at ';    echo date ('H:i:s, jS F Y.');    echo ' Godina';    echo '</p>';    echo '<p>You order is as follows: </p>';    echo $tireqty.' tires<br />';    echo $oilqty.' bootles oil<br />';    echo $sparkqty.' spark plugs<br />'; ?> </body> </html>

Rezultat je:

Fatal error: Can't use function return value in write context in C:\xampp\htdocs\bob1.php on line 3

offline
  • Dusan Kostic
  • @kosticdk
  • Pridružio: 24 Avg 2011
  • Poruke: 300
  • Gde živiš: Beograd

<?php //create short variable names if(isset($_POST['submit'])) { $tireqty = $_POST ['tireqty']; $oilqty = $_POST ['oilqty']; $sparkqty = $_POST ['sparkqty']; } ?> <html> <head>    <title>Bob's Auto Parts - Oreder Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php    echo '<p>Order processed at ';    echo date ('H:i:s, jS F Y.');    echo ' Godina';    echo '</p>';    echo '<p>You order is as follows: </p>';    echo $tireqty.' tires<br />';    echo $oilqty.' bootles oil<br />';    echo $sparkqty.' spark plugs<br />'; ?> </body> </html>

A u formi nemoj da stavljas tag IMPUT kao sto ti je rekao ikac, zato sto je napravio slovnu gresku i zbunio te, napisi sledece:

<input type="submit" name="submit" value="Posalji" />

offline
  • Pridružio: 17 Avg 2012
  • Poruke: 6

Sve sam otukucao kakao treba evo kod
<?php //create short variable names if (isset($_POST('submit')) {     $tireqty = $_POST ['tireqty'];     $oilqty = $_POST ['oilqty'];     $sparkqty = $_POST ['sparkqty']; } ?> <html> <input  type="submit" name = "submit" value = "Posalji" > <head>    <title>Bob's Auto Parts - Oreder Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php    echo '<p>Order processed at ';    echo date ('H:i:s, jS F Y.');    echo '</p>';    echo '<p>You order is as follows: </p>';    echo $tireqty.' tires<br />';    echo $oilqty.' bootles oil<br />';    echo $sparkqty.' spark plugs<br />'; ?> </body> </html>

i opet fatal error
Fatal error: Can't use function return value in write context in C:\xampp\htdocs\bob1.php on line 3

offline
  • lnenad  Male
  • Stručni saradnik
    Web
  • Nenad
  • Arhitetak
  • Pridružio: 16 Jan 2007
  • Poruke: 2860
  • Gde živiš: Bijeljina

Nisi, covjek ti je dobro ispravio trecu liniju, pogledaj opet.

offline
  • Pridružio: 17 Avg 2012
  • Poruke: 6

Ok sad sam vidjeo gdje je greska kod isset, ali opet nessto ne valja, sad mi pojavi ove greske:

Bob's Auto Parts Order Results Order processed at 09:05:51, 18th August 2012. Godina You order is as follows: Notice: Undefined variable: tireqty in C:\xampp\htdocs\bob1.php on line 23 tires Notice: Undefined variable: oilqty in C:\xampp\htdocs\bob1.php on line 24 bootles oil Notice: Undefined variable: sparkqty in C:\xampp\htdocs\bob1.php on line 25 spark plugs

offline
  • PHP Developer
  • Pridružio: 02 Okt 2005
  • Poruke: 546

Napisano: 18 Avg 2012 9:10

<?php //create short variable names $tireqty ="Greska"; $oilqty ="Greska"; $sparkqty ="Greska"; if (isset($_POST['tireqty'])) {     $tireqty = $_POST ['tireqty'];     $oilqty = $_POST ['oilqty'];     $sparkqty = $_POST ['sparkqty']; } ?> <html> <head>    <title>Bob's Auto Parts - Oreder Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php    echo '<p>Order processed at ';    echo date ('H:i:s, jS F Y.');    echo '</p>';    echo '<p>You order is as follows: </p>';    echo $tireqty.' tires<br />';    echo $oilqty.' bootles oil<br />';    echo $sparkqty.' spark plugs<br />'; ?> </body> </html>
Ovo bi trebalo da radi.
Tebi je submit form ocigledno u drugoj stranici.
$_POST je array i sa funkcijom isset() proveravas dali se elemant nalazi unutra pre nego sto ga koristis u suprotnom mozes da dobijed gresku da taj index ne postoji u nizu.
Takodje treba da setujes inicijalne vrednosti za proenjive koje ces koristiti.
Ti bi trebao da otvoris form stranicu uneses podatke i da te submin trebaci na ovu, a ne da ovu otvaras direktno.

Dopuna: 18 Avg 2012 9:13

Notice: Undefined variable: tireqty in C:\xampp\htdocs\bob1.php on line 23
ovo znaci da oces da koristis (ehujes) promenjivu koja nije nigde definisana posto kod nije usao unutar if-a

offline
  • Pridružio: 17 Avg 2012
  • Poruke: 6

Ok hvala sad je sve ok Ziveli

Moze lock na ovu temu Wink

offline
  • C# and PHP Developer
  • Pridružio: 16 Feb 2011
  • Poruke: 1625
  • Gde živiš: Pancevo

Pa taj primer imas u knjizi prikazan sto nas mucis? I imas na zadnjoj strani opis o greskama. Pogledaj malo...
Php i mysql - Razvoj aplikacija jel to ta knjiga bese?
http://www.mikroknjiga.rs/store/prikaz.php?ref=978-86-7555-340-3

Ko je trenutno na forumu
 

Ukupno su 398 korisnika na forumu :: 6 registrovanih, 0 sakrivenih i 392 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3028 - dana 22 Nov 2019 07:47

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: alexmiki, bato3, Dannyboy, ILGromovnik, Lep1na, Marko Marković