andrewsgreen Posted January 9, 2013 Share Posted January 9, 2013 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"' )) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/272888-error-incorrect-interger-value-colume-user2-row-1/ Share on other sites More sharing options...
haku Posted January 9, 2013 Share Posted January 9, 2013 From your post, I'd say that the problem is that there is an incorrect interger value for column user2 row 1. Quote Link to comment https://forums.phpfreaks.com/topic/272888-error-incorrect-interger-value-colume-user2-row-1/#findComment-1404420 Share on other sites More sharing options...
andrewsgreen Posted January 9, 2013 Author Share Posted January 9, 2013 could you please explain in m i am newquite new to this. Quote Link to comment https://forums.phpfreaks.com/topic/272888-error-incorrect-interger-value-colume-user2-row-1/#findComment-1404421 Share on other sites More sharing options...
haku Posted January 9, 2013 Share Posted January 9, 2013 It was my way of saying you didn't give us enough information. Copy the actual error message over. It will have a line number. Tell us which line it is. Quote Link to comment https://forums.phpfreaks.com/topic/272888-error-incorrect-interger-value-colume-user2-row-1/#findComment-1404422 Share on other sites More sharing options...
PFMaBiSmAd Posted January 9, 2013 Share Posted January 9, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/272888-error-incorrect-interger-value-colume-user2-row-1/#findComment-1404423 Share on other sites More sharing options...
andrewsgreen Posted January 9, 2013 Author Share Posted January 9, 2013 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"')) { Quote Link to comment https://forums.phpfreaks.com/topic/272888-error-incorrect-interger-value-colume-user2-row-1/#findComment-1404426 Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2013 Share Posted January 13, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/272888-error-incorrect-interger-value-colume-user2-row-1/#findComment-1405367 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.