lpxxfaintxx Posted April 7, 2006 Share Posted April 7, 2006 I wanted to use $_GET['sn'] and add it every time a user enters the page, but it won't work properly.For example, I go to [a href=\"http://aimmultimedia.com/viewprofile.php?id=username&\" target=\"_blank\"]http://aimmultimedia.com/viewprofile.php?id=username&[/a][b]sn=lpxxfaintxx[/b][code]<?phprequire_once "db.php";require_once "profileheader.php";$owner = $_GET['id'];$visitor = $_GET['sn']; $idq = mysql_query("SELECT `profilehits` FROM `fusion_users` WHERE `user_name` = '$owner'"); $ida = mysql_fetch_assoc($idq); $newid = $ida['profilehits'] + ', '.$visitor; $sql = "UPDATE fusion_users SET profilehits='$newid' WHERE user_name = '$owner'"; $result = mysql_query($sql);$sql = "SELECT * FROM `registered_cat` WHERE `owner` = '$owner'";$result=mysql_query($sql);$num_rows = mysql_num_rows($result);echo 'There are '.$num_rows. ' categories. Please choose one.<br><br>';while($row=mysql_fetch_array($result)){{$id = $row['id']; echo ' <a href="/viewprofilecat.php?id='.$id.'&sn=%n">'.$row['cat_name'].'</a> <br>' . "Description : {$row['cat_description']} <br>" . "Total Images : {$row['id']} <br> <hr>"; }}?>[/code]In MySQL, the row 'profilehits' is set to varchar, and default is 'anounymous'. So I was hoping it would store: Anounymous, lpxxfaintxx. But instead, it changes it to '0lpxxfaintxx'. Does anyone know how to fix this, or is there an easier way?Regards,AIMMultimedia.com - God Bless You Quote Link to comment Share on other sites More sharing options...
akitchin Posted April 7, 2006 Share Posted April 7, 2006 you are trying to mathematically add the two together when you use a + sign. this isn't javascript. try replacing the plus sign with a period; this is called the concatenation operator, which essentially glues two strings into one. Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted April 8, 2006 Author Share Posted April 8, 2006 Thanks, it works, but is there any way so that php can count how many commas there are? For example. anounymous, blahblah, lpxxfaintxx, php, yahoo would shout up as "4"Ive also tried[code]$sql2="SELECT profilehits FROM fusion_users WHERE user_name = '$owner'";$result2=mysql_query($sql2);$rows2=mysql_fetch_array($result2);$views = $rows2['profileviews'];$arr = explode(",", $views);[/code]But it just shows up as 1. Quote Link to comment 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.