放牧代码和思想
专注自然语言处理、机器学习算法
    愛しさ 優しさ すべて投げ出してもいい

Notice: Undefined variable: tireqty 解决

目录

这几天在看所谓的圣经PHP和MySQL_Web开发,结果第一个例子就出问题了:

Bob's Auto Parts

Order Results

Order processed at 11:55, 19th March

Your order is as follows:

Notice:  Undefined variable: tireqty in \xampp\htdocs\c1\processorder.php on line 14
tires

Notice:  Undefined variable: oilqty in \xampp\htdocs\c1\processorder.php on line 15
bottles of oil

Notice:  Undefined variable: sparkqty in \xampp\htdocs\c1\processorder.php on line 16
spark plugs

Notice:  Undefined variable: oilqty in \xampp\htdocs\c1\processorder.php on line 22

Notice:  Undefined variable: tireqty in \xampp\htdocs\c1\processorder.php on line 22

Notice:  Undefined variable: sparkqty in \xampp\htdocs\c1\processorder.php on line 22
Items ordered: 0

真叫人抓狂,于是谷歌之,挑了几个中文网页看看。喝,里面的人都要去改php.ini,把Notice干掉,这不是掩耳盗铃么,这相当于得了病自己把自己眼睛戳瞎。

看了还是几个老外说得对头,这本圣经已经是好多年前的古董了,很多语法现在都变得不规范了。老外是这么说的:

this is not the main issue tho. the book is using old php code. php doesnt work like this anymore.. when you send a varible using POST from one file to another you need to collect it in the second file

you do this by using

$tireqty=$_POST['tireqty'];

so add this code to the top of your process file before anything

<?php

$tireqty =$_POST['tireqty'];

$oilqty =$_POST['oilqty'];

$sparkqty =$_POST['sparkqty'];

$find =$_POST['find'];

?>

改好之后就是这个效果了:

知识共享许可协议 知识共享署名-非商业性使用-相同方式共享码农场 » Notice: Undefined variable: tireqty 解决

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    原来少了一行$find=$_POST[‘find’]; 解决了

    st632711年前 (2013-12-13)回复

我的作品

HanLP自然语言处理包《自然语言处理入门》