Jump to content

all database values not saving


jacobmaupin
Go to solution Solved by jacobmaupin,

Recommended Posts

Hello,

 

I have been working with this code for a long time and can't seem to find the problem. Im hoping this will be an obvious minor mistake on my part so here goes...

 

table only has 3 columns id, venu, and schedule. Problem is that when i click to save the "venu" field is left empty. I have opened up the database and looked to see what was saved - the id is generated and the date field is also correct but venu is blank. 

 

what am i doing wrong please help....

 

<?php
if(isset($_POST['add']))
{
 
$dbhost = 'xxxxxxxxx';
$dbuser = 'xxxxxxxxx';
$dbpass = 'xxxxxxxx';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
 
if(! get_magic_quotes_gpc() )
{
   $yourfield = addslashes ($_POST['venu']);
   $eventdate = addslashes ($_POST['schedule']);
}
else
{
   $yourfield = $_POST['venu'];
   $eventdate = $_POST['eventdate'];
}
 
$sql = "INSERT INTO live ".
       "(venu,schedule) ".
 
       "VALUES('$yourfield','$eventdate')";
 
 
mysql_select_db('liveshowinstruct');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Venu Name</td>
<td><input name="yourfield" type="text" id="yourfield"></td>
</tr>
<tr>
<td width="100">Date</td>
<td><input name="venu" type="text" id="venu"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="add" type="submit" id="add" value="Add Show">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>
Link to comment
Share on other sites

Your form inputs do not match what you are looking for when you process the form:

 

<td width="100">Venu Name</td>
<td><input name="yourfield" type="text" id="yourfield"></td>
</tr>
<tr>
<td width="100">Date</td>
<td><input name="venu" type="text" id="venu"></td>
</tr>
And you look for:

 

if(! get_magic_quotes_gpc() )
{
   $yourfield = addslashes ($_POST['venu']);
   $eventdate = addslashes ($_POST['schedule']);
}
else
{
   $yourfield = $_POST['venu'];
   $eventdate = $_POST['eventdate'];
}
You're not even consistent between the form and the block that checks for get_magic_quotes_gpc (and magic_quotes_gpc has been removed entirely from PHP so this always returns false now!)

 

I'm guessing you used a timestamp? Because you are not even getting a user submitted date with your current form input names and the variables you are looking for.

Link to comment
Share on other sites

Weird because the code works fine for everything except the venu field.

 

The "event date" is entered in the textbox and saved to the database with no problem.

Id is assigned incrementally no probs their either.

only part not working properly is the venu nothing saved.

 

Their is no time stamp, the textbox for event date can have any text placed into it rather its a date random text etc. So if my code works for setting the event date and the venu value is setup the exact same it seems to me it should work.

 

Im gathering from your post that you assume i have more code then you see here but that is not true this is the entire php script that i am using.

 

Are you saying that is should not be working at all?

 

1)"and magic_quotes_gpc has been removed entirely from PHP so this always returns false now!"

 

2)"Your form inputs do not match what you are looking for when you process the form:"

Link to comment
Share on other sites

I'm pointing out that the names of the form inputs do not match what you are using in the SQL script. If you look at those blocks i quuoted *carefully* you should notice the discrepencies.

 

For example, you look for $_POST['schedule'] in the !magicquotesgpc block and $_POST['eventdate'] in the magicquotesgpc section. Neither is correct because your form inputs have the names of 'venu' and 'yourfield'!

 

You also have them swapped, in the form.

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.