Jump to content

[SOLVED] Functions won't work together...


Aureole

Recommended Posts

I have these two functions inside a class...

 

<?php
function format_name_apos( $name )
{
$length = strlen( $name );
$last = substr( $name, -1, $length );
$this->output = ( $last == 's' ) ? $name.'\'' : $name.'\'s';
return $this->output;
}

function where($location)
{
$query = "UPDATE `members` SET `mem_where` = '{$location}' WHERE `mem_id` = '{$_SESSION['mem_id']}'";
$result = mysql_query( $query );
return( $result ) ? true : false;
}
?>

 

Now they both work fine, the first is to add an apostrophe to names that end in "s" and add an apostrophe followed by an s to names that don't end in "s".

 

The second is to update a Member's location in the Database...

 

The problem comes when I try to use the two together.

 

i.e.

 

<?php
$name = 'Fred';
$member->format_name_apos( $name );
$member_apos = $member->output;

$ptext = $member_apos . ' Profile';

$member->where( $ptext );
?>

 

The above just won't work, if I change $ptext to

 

$ptext = $name . ' Profile';

 

...then it will work.

 

Does anyone have any idea why this is happening?

Link to comment
https://forums.phpfreaks.com/topic/87887-solved-functions-wont-work-together/
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.