Jump to content

Problems with query for insert data from form


escobar

Recommended Posts

Hello,

 

I have a situation witch gave me a lot of headache. I have a simple form for inserting informations in a table, but my problem is that only the data with text values simply don't won't to be saved in my database. I tried a lot of combinations, and everything is ok, i can get the values of the variables like in the form, but i just can't store them in database. Please help, here is the code:

 

Form:

 

<form name="forma" action="form.php" method="post">
			<br />
			<fieldset>
				<legend><b>Chose day and month:</b></legend>
				<div class="class1">
					<select name="dayy">
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
					<option value="4">4</option>
					<option value="5">5</option>
					<option value="6">6</option>
					<option value="7">7</option>
					<option value="8">8</option>
					</select>
				</div>
				<div class="class2">
					<select name="monthh">
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
					<option value="4">4</option>
					<option value="5">5</option>
					<option value="6">6</option>
					<option value="7">7</option>
					<option value="8">8</option>
					</select>
				</div>
				<div class="class3">
					<select name="yearr">
					<option value="2011">2011</option>
					</select>
				</div>
			</fieldset>

			<table border="0">
				<tr>
					<td><b>Chose employe:</b></td>
					<td>
						<select name="emp">
							<option value="Name">Name</option>
							<option value="Name1">Name1</option>
							<option value="Name2">Name2</option>
							<option value="Name3">Name3</option>
						</select>
					</td>
				</tr>
				<tr>
					<td><b>Start:</b></td>
					<td>
						<select name="sum1">
							<option value="1">1</option>
							<option value="2">2</option>
							<option value="3">3</option>
							<option value="4">4</option>
							<option value="5">5</option>
						</select>
					</td>
				</tr>
				<tr>
					<td><b>End:</b></td>
					<td>
						<select name="sum2">
							<option value="1">1</option>
							<option value="2">2</option>
							<option value="3">3</option>
							<option value="4">4</option>
							<option value="5">5</option>
							<option value="6">6</option>
							<option value="7">7</option>
							<option value="8">8</option>
						</select>
					</td>
				</tr>
			</table>

			<input type="submit" name="submit" value="Send" />

</form>

Php code:

 

require_once "mysql_info.php";

$link = @mysql_connect($server, $username, $password);
if (!$link) {
echo "Error with server"; exit();
}

$bbaza = mysql_select_db($database, $link);
if (!$bbaza) {
echo "Error with database"; exit();
}


if (isset($_POST['submit'])) 
{
$day = $_POST['dayy'];
$month = $_POST['monthh'];
$year = $_POST['yearr'];

$person = $_POST['emp'];
$poc_rada = $_POST['sum1'];
$zav_rada = $_POST['sum2'];

}

$query = "INSERT INTO evidencija (djel, poc, zav, dan, mjesec, god) 
				    VALUES ($person, $poc_rada, $zav_rada, $day, $month, $year);";

$result = mysql_query($query);

if ($result) echo "<p>OK!!!</p>";
else echo "<p>Something is wrong!!!</p>";

mysql_close();

Weird thing is when i try to put some numbers instead of characters in employees field the insertion is ok, but when i try to use names and surnames the insertion does not work. And i have try to change column type from varchar, and text and it didnt work.

 

I hope someone will help me, thanks in advance!

 

 

 

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.