Find Jobs
Hire Freelancers

Fix PHP @ linking function ($15)

$10-30 CAD

Completed
Posted about 8 years ago

$10-30 CAD

Paid on delivery
I've got 1 function that links @ symbols like Twitter. A excellent coder could probably whiz this in half hour to and hour. I'm gonna post the function in the window, because I don't want to get a newb that can't help. Read the function, if you know the solution, you can fix for money. Bugs: when and unknown name, that isn't in my DB is first it won't link even the known names, but it will if the known name comes first. - if the DB connection fails, you’ll get an "cannot call method prepare() on null" error - preg_replace() does work, but you never save the modified string but return the original string. and you’ll also have a problem for similar usernames like "bob1" and "bob12" (the former tag also matches the latter) I need this to nail the tagging dead on, as in any professional app like twitter. I know my code is sloppy, but hope you can fix this. I'll require it working before money is release, so I'll want to test the function. ----- public function handle_user_link($str){ if( preg_match_all('/([@]+\w+)/', $str, $matches)){ $matches = array_slice($matches, 0, 1); for($i = 0; $i < count($matches); $i++) { // capture each tag $tag = $matches[0][$i]; $name = ltrim($tag, '@'); try{ $db = new PDO($this->db['dsn'], $this->db['username'], $this->db['password'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); }catch(\PDOException $e){} $sqlName = $db->prepare("SELECT `username` FROM `users` WHERE `username` = ?"); $sqlName->execute(array($name)); $retrievedUser = $sqlName->fetch(); if(!empty($retrievedUser)) { // tagged user exists. $str = str_replace($tag, '<a href="[login to view URL]'.$name.'">' . $tag . '</a>' , $str); } } } return $str; // End handle_user_link }
Project ID: 9831759

About the project

2 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
5 years of Experience in PHP & WordPress & Custom Wordpress Templates, I've designed 200+ websites in wordpress. My wordpress skills will be very helpful for this project. My recent works: Wordpress Sites: [login to view URL] [login to view URL] [login to view URL] [login to view URL] Online Store [login to view URL] [login to view URL] [login to view URL] [login to view URL] [login to view URL] Looking forward to have words with you. Regards, Sagar
$15 CAD in 1 day
5.0 (4 reviews)
2.8
2.8
2 freelancers are bidding on average $18 CAD for this job
User Avatar
Hello Sir/Madam, We have gone through the details you have provided and we have already worked on a similar project before and can deliver as u have mentioned and would be pleased to work on this with you to deliver the results that you have expected and we have already worked on a similar project before and can deliver as u have mentioned We are sure you will not be disappointed if you give us this opportunity. Our team is experienced, creative & efficient enough to get your job done well. We have an impeccable record and all our clients enjoy working with us, we are sure that you will too, our prices are cheapest in market. can u provide your email or sky-pe etc for further discussion about the project I am ready to discuss with you with best Regards
$25 CAD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
Hello I have gone through your function code i can solve your code easily. I have an 5 Years of experience in php programming contact me for more information thank you
$20 CAD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of CANADA
Grand Manan, Canada
5.0
24
Payment method verified
Member since Sep 30, 2014

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.