Jump to content

Post script not stacking.


GB_001

Recommended Posts

Hello for some reason my post script is not updating the database properly,

it doesn't stack it just overwrites.

 

 

<?php
session_start();
include('Connect.php');

$User=$_SESSION['email'];
$Friend=$_GET['F'];
$Comment=$_GET['C'];
$getN=mysql_query("SELECT * FROM Ysers WHERE email='$User'");
$row2 = mysql_fetch_array($getN);
$Name=$row2['Name'];
$PIC=$row2['Picture'];
$PIC="Images/$PIC"; 
list($width, $height, $type, $atrib) = getimagesize($PIC);
if($width>150||$height>200)
{
    $P=$width/100;
    $PH=$height/100;
    
    $MW=$width/$P;
    $MH=$height/$PH;
}

$pww=(360-$MW)-15;
$Time=date('Y-m-d');
$CF="<br><table valign=bottom height=40px width=360px style=\'color:white; background: black; border: 1px solid white; position:relative; left:80px;\'>
     <tr>
     <td COLSPAN=2 style=\'border-bottom: 1px solid white;\'>$Name -$Time</td>
     </tr>
     <tr>
     <td><img src=$PIC height=$MH width=$MW/></td><td width=150px valign=top style=\'padding: 15px;\'><p>$Comment</p></td>
     </tr>
     </table><gbbreaklinezero>";
     
$Cmenty=mysql_query("SELECT * FROM Ysers WHERE email='$Friend'");
$row = mysql_fetch_array($Cmenty);
$Commy=$row['Comments'];
mysql_query("UPDATE Ysers SET Comments='$CF $Commy' WHERE email='$Friend'");
?>

Link to comment
Share on other sites

Hello for some reason my post script is not updating the database properly,

it doesn't stack it just overwrites.

 

I mean that it just overwrites the column instead of keeping previous posts.

 

All these point in the direction that you should use INSERT instead of UPDATE. INSERT [as the name proposes] adds new records to the database, while UPDATE edits existing ones.

 

<?php
mysql_query("UPDATE table (col1, col2) VALUES ('value1', 'value2')");
?>

 

Link to comment
Share on other sites

For some reason it still doesn't work.

 

<?php
session_start();
include('Connect.php');

$User=$_SESSION['email'];
$Friend=$_GET['F'];
$Comment=$_GET['C'];
$getN=mysql_query("SELECT * FROM Ysers WHERE email='$User'");
$row2 = mysql_fetch_array($getN);
$Name=$row2['Name'];
$PIC=$row2['Picture'];
$PIC="Images/$PIC"; 
list($width, $height, $type, $atrib) = getimagesize($PIC);
if($width>150||$height>200)
{
    $P=$width/100;
    $PH=$height/100;
    
    $MW=$width/$P;
    $MH=$height/$PH;
}

$pww=(360-$MW)-15;
$Time=date('Y-m-d');
$CF="<br><table valign=bottom height=40px width=360px style=\'color:white; background: black; border: 1px solid white; position:relative; left:80px;\'>
     <tr>
     <td COLSPAN=2 style=\'border-bottom: 1px solid white;\'>$Name -$Time</td>
     </tr>
     <tr>
     <td><img src=$PIC height=$MH width=$MW/></td><td width=150px valign=top style=\'padding: 15px;\'><p>$Comment</p></td>
     </tr>
     </table><gbbreaklinezero>";
     
$Cmenty=mysql_query("SELECT * FROM Ysers WHERE email='$Friend'");
$row = mysql_fetch_array($Cmenty);
$Commy=$row['Comments'];
mysql_query("INSERT INTO Ysers (Comments) VALUE ($CF) WHERE email='$Friend'");
?>

Link to comment
Share on other sites

I just realized that i made a stupid mistake in my previous post, used UPDATE instead of INSERT  :-\

 

<?php
mysql_query("INSERT table (col1, col2) VALUES ('value1', 'value2')");
?>

 

Just insert the row, it will be automatically added. Your query may be something like, instead of the WHERE part:

mysql_query("INSERT INTO Ysers (Comments, email) VALUES ('$CF', '$Friend')");

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.