Jump to content

error: incorrect interger value colume user2 row 1


andrewsgreen

Recommended Posts

error: incorrect interger value colume user2 row 1.

 

IT FOR REPLYING TO PERSONAL MESSAGES THATS NOT WORKING.

 

 

 

<?php

if(isset($_SESSION['username']))

{

if(isset($_GET['id']))

{

$id = intval($_GET['id']);

$req1 = mysql_query('select title, user1, user2 from pm where id="'.$id.'" and id2="1"');

$dn1 = mysql_fetch_array($req1);

if(mysql_num_rows($req1)==1)

{

if($dn1['user1']==$_SESSION['userid'] or $dn1['user2']==$_SESSION['userid'])

{

if($dn1['user1']==$_SESSION['userid'])

{

mysql_query('update pm set user1read="yes" where id="'.$id.'" and id2="1"');

$user_partic = 2;

}

else

{

mysql_query('update pm set user2read="yes" where id="'.$id.'" and id2="1"');

$user_partic = 1;

}

$req2 = mysql_query('select pm.timestamp, pm.message, users.id as userid, users.username, users.avatar from pm, users where pm.id="'.$id.'" and users.id=pm.user1 order by pm.id2');

if(isset($_POST['message']) and $_POST['message']!='')

{

$message = $_POST['message'];

if(get_magic_quotes_gpc())

{

$message = stripslashes($message);

}

$message = mysql_real_escape_string(nl2br(htmlentities($message, ENT_QUOTES, 'UTF-8')));

if(mysql_query('insert into pm (id, id2, title, user1, user2, message, timestamp, user1read, user2read)values("'.$id.'", "'.(intval(mysql_num_rows($req2))+1).'", "", "'.$_SESSION['userid'].'", "", "'.$message.'", "'.time().'", "", "")') and mysql_query('update pm set user'.$user_partic.'read="yes" where id="'.$id.'" and id2="1"' ))

{

?>

Link to comment
Share on other sites

Given that you are trying to insert an empty string '' into the user2 column, I would expect that error.

 

BTW - you cannot use data values derived from - mysql_num_rows($req2))+1. In modern, multi-taking, interrupt-driven, operating systems, concurrent operations can change the number of rows in a table, making that value incorrect. If you need a specific id value, you need to get that actual value from where it is being assigned.

Link to comment
Share on other sites

Incorrect integer value: '' for column 'user2' at row 1

 

}

$message = mysql_real_escape_string(nl2br(htmlentities($message, ENT_QUOTES, 'UTF-8')));

if(mysql_query('insert into pm (id, id2, title, user1, user2, message, timestamp, user1read, user2read)values("'.$id.'", "'.(intval(mysql_num_rows($req2))+1).'", "", "'.$_SESSION['userid'].'", "", "'.$message.'", "'.time().'", "", "")') and mysql_query('update pm set user'.$user_partic.'read="yes" where id="'.$id.'" and id2="1"'))

{

Link to comment
Share on other sites

I looked at your posted code to try and figure out what you are doing in it, and I recommend that you first define what you are trying to accomplish, then write the code to do it. You have extra/repeated code, data, and queries that doesn't do anything toward your goal of replying to a PM.

 

If you define what data you are trying to INSERT into each column, you should be able to write your INSERT query to do what you want.

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.