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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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