Find Jobs
Hire Freelancers

Fix PHP @ linking function ($15)

$10-30 CAD

已完成
已发布大约 8 年前

$10-30 CAD

货到付款
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 }
项目 ID: 9831759

关于此项目

2提案
远程项目
活跃8 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
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 在1天之内
5.0 (4条评论)
2.8
2.8
2威客以平均价$18 CAD来参与此工作竞价
用户头像
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 在1天之内
0.0 (0条评论)
0.0
0.0
用户头像
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 在1天之内
0.0 (0条评论)
0.0
0.0

关于客户

CANADA的国旗
Grand Manan, Canada
5.0
24
付款方式已验证
会员自9月 30, 2014起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。