SlinkyABC Posted October 24, 2011 Share Posted October 24, 2011 Hi, I'm not sure if this is the right place to post this but it seems to be acceptable. Please let me know if it's out of line, though. I recently started learning PHP and am going through PHP and MYSQL Web Development. It seems like a pretty good book so far. Currently I'm working through the code in chapter 1 and am running into an issue. From what I can tell, the code I should have at this point is as follows: <html> <head> <title>Bob's Auto Parts - Order Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php // create short variable names $tireqty = $_POST('tireqty'); $oilqty = $_POST('oilqty'); $sparkqty = $_POST('sparkqty'); echo "<p>Order processed at "; echo date('H:i, jS F Y'); echo "</p>"; echo "<p>Your order is as follows: </p>"; echo $tireqty.' tires<br />'; echo $oilqty.' bottles of oil<br />'; echo $sparkqty.' spark plugs<br /'>'; ?> </body> </html> Within the PHP script, two particular blocks of code seem to be giving me problems: $tireqty = $_POST('tireqty'); $oilqty = $_POST('oilqty'); $sparkqty = $_POST('sparkqty'); and echo "<p>Your order is as follows: </p>"; echo $tireqty.' tires<br />'; echo $oilqty.' bottles of oil<br />'; echo $sparkqty.' spark plugs<br /'>'; Without these two blocks, the rest of the PHP executes but when I add one or both of these the PHP doesn't show up at all; instead it only executes the HTML and the output from the PHP doesn't show up. IF I remove these and only keep the "Order processed at" part of the script, that part executes fine. I've gone through the code in the book and it seems like what I have is correct. As soon as I try to define or call any of the variables, it seems to break the code. Any ideas? Sorry to bother you with such a basic question but I can't seem to locate a problem with this code based on what I've been taught so far. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/249746-php-and-mysql-web-development/ Share on other sites More sharing options...
requinix Posted October 25, 2011 Share Posted October 25, 2011 Those need to be square brackets: $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; Square brackets mean arrays (or strings (which are like arrays of characters, really)) while parentheses mean functions. $_POST is an array, so to get something inside it you need []s. Everything else looks right. Quote Link to comment https://forums.phpfreaks.com/topic/249746-php-and-mysql-web-development/#findComment-1281942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.