Jump to content

Ugh. Data not getting inserted into mysql database.


Alex1646

Recommended Posts

Ugh. Ive been asking so many questions, betcha already know my name. Hahah.

Anyways, I know I already asked a question like this, but this is different.

One of the values I am trying to insert into a database is simply not working.

Here is the columnes in my mysql database:


 

c_id  commet      story  user      date_added  star


Every value but 'commet' is getting inserted into database.  NO error, no mysql errror. I have racked my brain trying to figure out what is wrong with the script.

Here is my code:

<?php
$idget = $_GET['id'];
mysqlConnect();
//submit story
if(isset($_POST['submit']))
{
   $com_form = mysql_real_escape_string(bb($_POST['commet']));
   $rat_form = $_POST['rat'];
   $story_form =  $idget;
   $user = $_SESSION['user'];
   $date = date("Y-m-d");
   $query1 = "
   INSERT INTO story_commets(star, story, user, date_added, commet)
   VALUES($rat_form, '$story_form', '$user', '$date', '$com_form')
   ";
   mysql_query($query1) or die(mysql_error());


      
      
   //}
}

// desplay reviews


$query3 = "
SELECT * FROM story_commets
WHERE story = '$idget'
ORDER BY date_added
";
$select3 = mysql_query($query3) or die(mysql_error());
//$x=1;
$ratav = array();
//if(mysql_num_rows($select3) == 0)
//{
   echo '<div id="message"> No Reviews Yet.... <>';
   
//}
//else
//{
while($rows3 = mysql_fetch_assoc($select3))
{
   
   
   $commetdb = $rows3['commet'];
   $user_com_db = $rows3['user'];
   $datedb = $rows3['date_added'];
   $stardb = $rows3['star'];
   //get profile picture
   $query4 = "
   SELECT * FROM login_info
   WHERE user = '$user_com_db'
   ";   
   $select4 = mysql_query($query4) or die(mysql_error());
   
   $rows4 = mysql_fetch_assoc($select4) or die(mysql_error());
      $profile_pic = $rows4['profile_picture'];
      $user_id = $rows4['id'];
   echo "
   <div class='rev_cont'>
   <div class='info'>
   <img src='$profile_pic' /> 
   <a href=?p=profile&id=$user_id> $user_com_db </a> 
   

   
   <> <br /> 
   <div class='rev'>
   <strong> $stardb/10 </strong> <br />
   $commetdb
   <> 
   <div id='date'>  <em> Date Added: $datedb </em> <> 
   <>
   <hr />
   
   
     ";
   
   $ratav[]=$stardb; 
   
     
     
}




$sum = array_sum($ratav);

$count = count($ratav);
$av = $sum / $count;
$avf = round($av, 1);
echo"<div id='message'> Rating Avarage: $avf /10 <>";
//}
if (isset($_SESSION['user']))
{
   echo"
   <p> Did you like this story? Did you hate it? Give it a rating and let the author know!</p>
<form action='?p=review&id=$idget' method='post'  target='_self'> 

<label> Your rating is on a scale of 1-10 </label>
<select name='rat'>
    <option> 1 </option>
    <option> 2 </option>
    <option> 3 </option>
    <option> 4 </option>
    <option> 5 </option>
    <option> 6 </option>
    <option> 7  </option>
    <option> 8 </option>
    <option> 9 </option>
    <option> 10 </option>
</select>
<label> Commets: </label>

<textarea name='commet' cols='70' rows='9'></textarea>
<input name='story' type='hidden' value='$idget' /> <br />
<input type='submit' value = 'Post' name='submit' />
</form>

   ";
}
else 
{
   echo "<div id='message'> Sign in to post a review! <>";
}

?>



Here are the specifics if you want it.

 

Here is the response part of the code:

<?php
if(isset($_POST['submit']))
{
   $com_form = mysql_real_escape_string(bb($_POST['commet']));
   $rat_form = $_POST['rat'];
   $story_form =  $idget;
   $user = $_SESSION['user'];
   $date = date("Y-m-d");
   $query1 = "
   INSERT INTO story_commets(star, story, user, date_added, commet)
   VALUES($rat_form, '$story_form', '$user', '$date', '$com_form')
   ";
   mysql_query($query1) or die(mysql_error());


      
      
   //}
}
?>

Here is the form part of my code:

<?php
if (isset($_SESSION['user']))
{
   echo"
   <p> Did you like this story? Did you hate it? Give it a rating and let the author know!</p>
<form action='?p=review&id=$idget' method='post'  target='_self'> 

<label> Your rating is on a scale of 1-10 </label>
<select name='rat'>
    <option> 1 </option>
    <option> 2 </option>
    <option> 3 </option>
    <option> 4 </option>
    <option> 5 </option>
    <option> 6 </option>
    <option> 7  </option>
    <option> 8 </option>
    <option> 9 </option>
    <option> 10 </option>
</select>
<label> Commets: </label>

<textarea name='commet' cols='70' rows='9'></textarea>
<input name='story' type='hidden' value='$idget' /> <br />
<input type='submit' value = 'Post' name='submit' />
</form>

   ";
}
else 
{
   echo "<div id='message'> Sign in to post a review! <>";
}
?>

Its probably something really mundane. HelP!

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.