Pls help:)
Can someone pls check the errors. I am unable to insert the data into the database.
@e.mccormick
Are you able to see the database log? Does it do a connection fromt the page to the database?
ya.
See, if the PHP structure is correct, the place to look is in the web and database server logs. They can have info on things like if the table exists, was there an error there, and so on. You can also try the query directly on the SQL server to make sure a record works, then try to read that record using PHP. That helps confirm the overall structure.
oh k. I tried to insert direct values using php. worked fine. but i can't insert the form data
Ah, good. OK. So you know that the different services are talking. Hmmm. Can you get information from a form and just display it?
ya but it is not working for the above form. I am so lost. I am unableto figure out the mistake. I checked the syntax. but am unable to find any mistake
OK, so it is some minor syntax issue in the form. PHP or HTML. I see some differences in the if on this page: http://stackoverflow.com/questions/17333901/php-form-on-sumbit-stay-on-same-page ``` <?php if(isset($_POST['SubmitButton'])){ //check if form was submitted $input = $_POST['inputText']; //get input text echo "Success! You entered: ".$input; } ?> <html> <body> <form action="" method="post"> <input type="text" name="inputText"/> <input type="submit" name="SubmitButton"/> </form> </body> </html> ``` That seems to be the same sort of single page post you are doing. Perhaps the `if(isset($_POST['SubmitButton']))` is needed to capture the button hit, as opposed to your `if ($_POST) `.
if ($_POST) is good syntax, it's a shortcut way of saying if (isset($_POST)) just giving it a quick look, everything seems to be in order. 2 things to check, 1) after your if($_POST) check, add: echo '<pre>'; print_r($_POST); exit; That will give you a human readable output of the POST array to make sure you're getting the names and values that you're expecting. If that looks good, then after your query is assigned to $sql, add a die($sql); to see what the output being sent to your database looks like. Also, you should keep in mind that PDO for database interactions is considered the best practice, it's faster, and more secure and works with almost any database driver if you ever move away from mysql. It's fairly easy to implement whether you prefer OOP or procedural php. If the issue doesn't jump out at you after those outputs (like doubled quotes around string values etc) post the output and I'll take a look.
Also let me know if you want help implementing or researching PDO, it will make your life so much easier
thanx a lot. phpmyadmin is not working. i get this error. Parse error: syntax error, unexpected 'implements PMA_StringByte' (T_ENCAPSED_AND_WHITESPACE), expecting '{' in C:\xampp\phpMyAdmin\libraries\StringMB.class.php on line 26 but there is only a comment in that line. it worked fine earlier. I dnt knw what happened suddenly.
It is workin nw.:D
I have stored the price of chairs in one table and the quantity in other table.How do i find the total cost? @seandisanti @e.mccormick
@hartnn
well, not knowing anything about your schema, this answer assumes you have a fullfillment table where each record is for a purchase of a single product from a products table and multiple rows from the fullfillment table can be associated with an order from an orders table. : SELECT p.name, p.price * f.quantity as line_total FROM fullfillment f INNER JOIN orders o ON f.order_id = o.id INNER JOIN products p on f.product_id = p.id WHERE o.id = $order GROUP BY o.id, p.id With the structure outlined above, this will return a record for each product on an order (specified in $order) and return the cost times the quantity along with the name. You'll probably have to adjust this to fit your own schema but hopefully the query makes enough sense now that you can
Join our real-time social learning platform and learn together with your friends!