loganbest Posted August 18, 2007 Share Posted August 18, 2007 I have this code to enter stuff into my db, When someone views a profile it's supposed to add 1 to the views column but it doesn't. This is the latter of the code that matters. $who = intval($who); $shared = mysql_query("select * from userdb where id=" . $who . ""); $sharedinfo = mysql_fetch_array($shared); /* Add hit */ if($sharedinfo[id] != $playerinfo[id]) { if($playerinfo[name] != "") { $t1mnow = time(); $startletter = $playerinfo[id]{0}; $whoviewed = defaultpic($playerinfo[id],"viewedlink"); if($who != 5) { $r = mysql_fetch_array(mysql_query("SELECT ghost FROM userdb WHERE id='$playerinfo[id]' LIMIT 1")); if($r[ghost] == 0) { mysql_query("insert into profileviews set whoviewed='" . $whoviewed . "', whoseprofile=$sharedinfo[id], lastin=" . $t1mnow . "") or die(); } } } } /* Add hit part 2 */ if($who != 5) { if($c_email != "") { if($playerinfo[id] != "$sharedinfo[id]") { if($playerinfo[lastviewed] != "$sharedinfo[id]") { if($sharedinfo[views] >= "1") { mysql_unbuffered_query("update userdb set views=1, newviews=1 where id=" . $sharedinfo[id] . ""); }else{ $ghost = mysql_query("SELECT ghost FROM userdb WHERE id=". $playerinfo[id]. " LIMIT 1"); $r = @mysql_fetch_array($ghost); if($r[ghost] == 0) { mysql_unbuffered_query("update userdb set views='views+1', listviews='listviews+1', newviews=1, friends=" . $net . " where id=" . $sharedinfo[id] . ""); }else{ mysql_unbuffered_query("update userdb set views='views+1', listviews='listviews+1', friends=" . $net . " where id=" . $sharedinfo[id] . ""); } } } } }else{ mysql_unbuffered_query("update userdb set views='views+1', friends=" . $net . " where id=" . $sharedinfo[id] . ""); } } Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/ Share on other sites More sharing options...
Masna Posted August 18, 2007 Share Posted August 18, 2007 This works throughout... Change views='views+1' to views=`views`+1 Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327753 Share on other sites More sharing options...
loganbest Posted August 18, 2007 Author Share Posted August 18, 2007 still doesn't work...everything else in the query goes through except for views and listviews...I'm using php 4.4.7 Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327759 Share on other sites More sharing options...
matthewhaworth Posted August 18, 2007 Share Posted August 18, 2007 still doesn't work...everything else in the query goes through except for views and listviews...I'm using php 4.4.7 views='views+1' Take it out of the quotes so it's not passed as a string views=views+1 Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327782 Share on other sites More sharing options...
loganbest Posted August 18, 2007 Author Share Posted August 18, 2007 the quotes weren't there in the first place...I put those in thinking it would solve it. Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327787 Share on other sites More sharing options...
BlueSkyIS Posted August 18, 2007 Share Posted August 18, 2007 if nothing else, you probably need to wrap some of your arrays, for instance: {$sharedinfo[id]} I always try to consistently single-quote every field. Sometimes you do, sometimes you don't. If you made it consistent, that might help you fix the problem. Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327790 Share on other sites More sharing options...
loganbest Posted August 18, 2007 Author Share Posted August 18, 2007 if nothing else, you probably need to wrap some of your arrays, for instance: {$sharedinfo[id]} I always try to consistently single-quote every field. Sometimes you do, sometimes you don't. If you made it consistent, that might help you fix the problem. I don't quite get where you want me to wrap my array. Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327792 Share on other sites More sharing options...
loganbest Posted August 19, 2007 Author Share Posted August 19, 2007 any other solutions? Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327865 Share on other sites More sharing options...
matthewhaworth Posted August 19, 2007 Share Posted August 19, 2007 A good little trick is to apply the query to phpmyadmin and copy and past it, changing the variable names to ensure you've got the syntax correct. Quote Link to comment https://forums.phpfreaks.com/topic/65631-data-not-being-passed-into-db/#findComment-327880 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.