Jump to content

MySQL Update Problem


lpxxfaintxx

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]

[code]<?php
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'";
$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
Link to comment
https://forums.phpfreaks.com/topic/6845-mysql-update-problem/
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'";
$result2=mysql_query($sql2);
$rows2=mysql_fetch_array($result2);
$views = $rows2['profileviews'];
$arr = explode(",", $views);[/code]

But it just shows up as 1.
Link to comment
https://forums.phpfreaks.com/topic/6845-mysql-update-problem/#findComment-25001
Share on other sites

Archived

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

×
×
  • 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.