freddy_1992 Posted March 1, 2011 Share Posted March 1, 2011 <form method="post" > <fieldset> <table> <tr> <td>naam van het gerecht:</td> <td><input type="text" name="nieuwgerecht" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 1:<input type="text" name="ingredient1" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 2:<input type="text" name="ingredient2" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 3:<input type="text" name="ingredient3" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 4:<input type="text" name="ingredient4" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 5:<input type="text" name="ingredient5" /></td> </tr> </table> <input type="submit" name="cmdvoegtoe" value="voeg toe" /> </fieldset> </form> <?php if(isset($_POST['cmdvoegtoe'])) { if (empty($_POST['ingredient1'])) { echo "<script>alert(\"ingredient nummer 1 moet zeker ingevuld zijn!\");</script>"; } else { $query="INSERT INTO tblgerecht VALUES(NULL, '$_POST[nieuwgerecht]')"; mysql_query($query, $connectie) or die('Error, insert query failed'); } } ?> Parse error: parse error in ... on line 118 problem with mysql query can someone help me with it Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/ Share on other sites More sharing options...
Muddy_Funster Posted March 1, 2011 Share Posted March 1, 2011 1: put your code in the php tags 2: post the full page of code 3: post the full error message 4: post your table structure 5: Read the Forum Guidelines! (honestly - they are there for a reason, had you read them alredy I could be posting back something much more helpfull to your cause) Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181179 Share on other sites More sharing options...
freddy_1992 Posted March 1, 2011 Author Share Posted March 1, 2011 1: put your code in the php tags 2: post the full page of code 3: post the full error message 4: post your table structure 5: Read the Forum Guidelines! (honestly - they are there for a reason, had you read them alredy I could be posting back something much more helpfull to your cause) 1. i have put my code in php tags 2. the excersice is in 2parts, the 1parts works but the second not 3. that is the error but the ... is the folder 4. my table is there in code 5. only post when you think you got the answer thank you! Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181181 Share on other sites More sharing options...
PFMaBiSmAd Posted March 1, 2011 Share Posted March 1, 2011 The code you posted doesn't produce a php parse error. In fact, the code you posted doesn't even have 118 lines. We can only help you when you post the actual code that produces the error. When posting code, please put it inside the forum's ... tags. Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181184 Share on other sites More sharing options...
Muddy_Funster Posted March 1, 2011 Share Posted March 1, 2011 wooo, aint you cheeky :- not the best way to go about getting help. I'll try again, on the off chance you fell off that high horse. 1: the php tags I reffer to are the forums php tags these format the code in a way that makes life easier for all concerned. 2: there is no way 118 lines in that code you posted - so clearly something is missing. 3: the ... also contains the file name that has the error - helpful if you have used an include anywhere in the code you didn't post. 4: the STRUCTURE is not in your code as this reffers to table name, field name, field type, any fileds that are keys, any indexed fields and any fields that are auto incramented. 5: It's impossable to answer without the relevant information! Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181186 Share on other sites More sharing options...
freddy_1992 Posted March 1, 2011 Author Share Posted March 1, 2011 hmm very strange i come back from office try it to fix it @home and i have no parse error anymore only my query does'nt work it always say:Error, insert query failed <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body bgcolor="#FF9900" text="#330000" style="font-size:16px" style="font-family:'Courier New', Courier, monospace" /> <?php include('1connectie.php'); $sql_statement="SELECT * FROM tblgerechten"; $weergave=mysql_query($sql_statement,$connectie); ?> <form method="POST"> <fieldset> <legend> kies je menu'tjes </legend> <thead> <tr>kies </tr><tr> Gerechten </tr> <br /> </thead> <?php while($data=mysql_fetch_assoc($weergave)) { ?> <input type="checkbox" name="gerechten[]" value="<?php echo $data['gerechtenid'];?>"/> <?php echo $data['gerecht']; ?> <br /> <?php } ?> <input type="submit" name="btnverzenden" value="verzenden" /> </fieldset> </form> <?php if(isset($_POST['btnverzenden'])) //knop gedrukt? { if(isset($_POST['gerechten'])) // zijn gerechten aangeduid { foreach($_POST['gerechten'] as $gerecht) //!!!!!opgelet geen [] { if(isset($gerecht)) $sql="SELECT ingredient FROM tblingredienten WHERE gerechtid = '".$gerecht."'"; $data = mysql_query($sql); while ($rij=mysql_fetch_assoc($data)) { echo $rij['ingredient'].'<br />'; } } } else echo 'Geen gerechten geselecteerd ...'; } ?> <form method="post" > <fieldset> <table> <tr> <td>naam van het gerecht:</td> <td><input type="text" name="nieuwgerecht" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 1:<input type="text" name="ingredient1" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 2:<input type="text" name="ingredient2" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 3:<input type="text" name="ingredient3" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 4:<input type="text" name="ingredient4" /></td> </tr> <tr> <td></td> <td></td> <td>ingredient 5:<input type="text" name="ingredient5" /></td> </tr> </table> <input type="submit" name="cmdvoegtoe" value="voeg toe" /> </fieldset> </form> <?php if(isset($_POST['cmdvoegtoe'])) { if (empty($_POST['ingredient1'])) { echo "<script>alert(\"ingredient nummer 1 moet zeker ingevuld zijn!\");</script>"; } else { $query="INSERT INTO tblgerecht(gerecht) VALUES('$_POST[nieuwgerecht]')"; mysql_query($query, $connectie) or die('Error, insert query failed'); } } ?> </body> </html> i have to 2tabel in mysql: 1) tblgerecht (gerechtenid(INT, primarykey,autoincrement) AND gerecht(VARCHAR) ) 2)tblingredient (gerechtid(INT) AND ingredient(VARCHAR) can someone help me now Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181208 Share on other sites More sharing options...
PFMaBiSmAd Posted March 1, 2011 Share Posted March 1, 2011 Use mysql_error() to find out why your query failed. Change your code to the following - mysql_query($query, $connectie) or die('Error, insert query failed ' . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181211 Share on other sites More sharing options...
freddy_1992 Posted March 1, 2011 Author Share Posted March 1, 2011 Error, insert query failed Table 'dbcolruyt.tblgerecht' doesn't exist my databank name is dbcolruyt my tabel is tblgerecht why does it say that it is not excist :s Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181216 Share on other sites More sharing options...
Muddy_Funster Posted March 1, 2011 Share Posted March 1, 2011 at a glance, I would change: $query="INSERT INTO tblgerecht(gerecht) VALUES('$_POST[nieuwgerecht]')"; to $query="INSERT INTO tblgerecht (gerecht) VALUES ('".$_POST['nieuwgerecht']."')"; and see how that goes. Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181218 Share on other sites More sharing options...
PFMaBiSmAd Posted March 1, 2011 Share Posted March 1, 2011 Probably because your table is actually named: tblgerechten Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181223 Share on other sites More sharing options...
Muddy_Funster Posted March 1, 2011 Share Posted March 1, 2011 ... i have to 2tabel in mysql: 1) tblgerecht (gerechtenid(INT, primarykey,autoincrement) AND gerecht(VARCHAR) ) ... Probably because your table is actually named: tblgerechten DOH! Good Catch PFM Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181227 Share on other sites More sharing options...
freddy_1992 Posted March 1, 2011 Author Share Posted March 1, 2011 thx for help guys it worked now Quote Link to comment https://forums.phpfreaks.com/topic/229237-problem-with-querys-s/#findComment-1181228 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.