Jump to content


This topic is now archived and is closed to further replies.


MySQL Update Problem

Recommended Posts

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]

require_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'";
$num_rows = mysql_num_rows($result);
echo 'There are '.$num_rows. ' categories. Please choose one.<br><br>';
$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>";


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?

AIMMultimedia.com - God Bless You

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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'";
$views = $rows2['profileviews'];
$arr = explode(",", $views);[/code]

But it just shows up as 1.

Share this post

Link to post
Share on other sites


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.