Re: cant insert into specific column in specific row...help?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aj Seelund wrote:

im trying to insert, or more or less, add to the number in a column called (comNum) in one a specific row in one table(dm_blog), and add other values to another table(comments).

i have the comments table working fine, everything insert correctly, but im trying to add to the count (comNum) in dm_blog. im not quite sure how to go about doing this... im trying to select the cell and then add a value to it, but my targeting is off i think.

heres a sample of the code im using:

//if posting a comment do this:
if ($comms=="true") {
//create a row in comments table $id is post number from dm_blog
$id = $entryNum;
if ($newTab=="true") {
//set comNum to 1 if no comment yet
$comNum = 1;

>


//insert the values into the table for the comment
$commPost = "INSERT INTO comments VALUES ('$id','$daUser', '$entryNumb', '$priv', '$comm')";
$add_to_comNum = 'SELECT `comNum` '
. ' FROM `dm_blog` '
. ' WHERE 1 AND `entryNum` = ' . $id .' LIMIT 0, 30';

//this is where im confused...


$commAdd = "INSERT INTO dm_blog VALUES ('$id','$daUser', '$entryNumb', '$priv', '$comm')";
$addComm = mysql_query($add_to_comNum) or die("error selecting and inserting $comNum into comNum on $id");
//output the comment or errors
$CommResult = mysql_query($commPost) or die("(Error on line 70 of inputBlog.php) <br /><br /> tableName:$theTable <br /> entryNum:$entryNum <br /> entryNumb:$entryNumb<br /> priv:$priv <br />usr:$daUser<br /> comm:$comm");
}else{
//insert the values into the table for the comment
$commPost = "INSERT INTO comments VALUES ('$id','$daUser', '$entryNumb', '$priv', '$comm')";
$post = "INSERT INTO dm_blog VALUES ('$comNum')";


//output the comment or errors
$CommResult = mysql_query($commPost) or die("(Error on line 78 of inputBlog.php) <br /><br /> tableName:$theTable <br /> entryNum:$entryNum <br /> priv:$priv <br />usr:$daUser<br /> comm:$comm");
$result2 = mysql_query($post) or die("(Error on line 85 of inputBlog.php) <br /> $post </td> \n\r </tr> \n\r </table> </body></html>");
}


while($myrow = mysql_fetch_array($CommResult)){
$p_entryNumb = $myrow["entryNumb"];
$p_daUser = $myrow["daUser"];
echo "entryNumber: $p_entryNumb by [user: $p_daUser] has been added<br />";
}


    //if posting a new post in dm_blog do this:
}else{

$post = "INSERT INTO dm_blog VALUES ('$date', '$chapter', '$mood', '$theuser', '$message', '$entryNum' ,'$song','$t_level','$r_thought','$comNum')";
$result = mysql_query($post) or die("Uh oh! You fucked up dumbass! (Error on line 85 of inputBlog.php) <br /> $post </td> \n\r </tr> \n\r </table> </body></html>");


}


thanks in advance

-aj seelund
aj@xxxxxxxxxxxxxxxx

If you're trying to add to a column or change a field, you should be using an UPDATE SQL statement.


--
paperCrane <Justin Patrin>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux