Jump to content

Problem with query's :s


freddy_1992

Recommended Posts

  <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 :)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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 :)

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.