Aureole Posted January 26, 2008 Share Posted January 26, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/87887-solved-functions-wont-work-together/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 26, 2008 Share Posted January 26, 2008 Have you echoed $ptext to see what it actually contains? Quote Link to comment https://forums.phpfreaks.com/topic/87887-solved-functions-wont-work-together/#findComment-449676 Share on other sites More sharing options...
Aureole Posted January 26, 2008 Author Share Posted January 26, 2008 Solved. The query had an apostrophe in which wasn't being escaped and I wasn't doing anything like or die(mysql_error()) in my queries so I didn't realize. mysql_real_escape_string() seemed to do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/87887-solved-functions-wont-work-together/#findComment-449677 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.