Find Jobs
Hire Freelancers

Fix My @ Tagging Class (Want it to work like Twitter) ($90)

$30-250 CAD

ถูกยกเลิก
โพสต์ ประมาณ 8 ปีที่ผ่านมา

$30-250 CAD

ชำระเงินเมื่อส่งงาน
I need a good php coder that knows what they're doing. I just lost $15 so decided it would take more. This has to be WORKING before I release funds. Please do not apply for the sake of applying. Read the job! I have a function that is supposed to wrap a link around any username with an @ symbol in front of it. Right now it only partially works. It will work on names in the DB if the known name comes first. say JeremyBenson11 is in the DB if the string is "Hello @JeremyBenson11 how are you." It will wrap and <a></a> tag around it. If the string is "There's @bob11 going with @JeremyBenson11" It will not wrap the link around @JeremyBenson11 These are the known BUGS and Issues: there are 2 issues: - 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. issue #1: 1) never ever create DB connections inside a loop. 2) catch the exception where you can handle the problem. obviously that is not inside this method so the try..catch should be around that class (at most). issue #3: you’ve already found str_replace(). note: the braces in [@]+ are superfluous. a character class of a single character equals that character. note: by using @+(\w+) you get the username directly note: foreach ($matches[1] as $name) ... The function below look over it. PLEASE do not waste my time and money. If you suggest to put a variable in a prepared string as the solution I will NOT pay you. --- 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($dsn, $dbUsername, $dbPassword, 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 }
รหัสโปรเจกต์: 9832071

เกี่ยวกับโปรเจกต์

2 ข้อเสนอ
โปรเจกต์ระยะไกล
ใช้งานอยู่ 8 ปีที่ผ่านมา

กำลังมองหาการสร้างรายได้ใช่ไหม?

ประโยชน์ของการประมูลกับ Freelancer

กำหนดงบประมาณและกรอบเวลาของคุณ
รับเงินจากการงานของคุณ
อธิบายข้อเสนอของคุณในภาพรวม
ลงทะเบียนและเสนอราคาฟรี

เกี่ยวกับลูกค้า

ปักธงของ CANADA
Grand Manan, Canada
5.0
31
ยืนยันวิธีการชำระเงินแล้ว
เป็นสมาชิกตั้งแต่ ก.ย. 30, 2014

การยืนยันลูกค้า

ขอบคุณ! เราได้ส่งลิงก์สำหรับเครดิตฟรีให้คุณทางอีเมลแล้ว
เกิดข้อผิดพลาดขณะส่งอีเมลของคุณ กรุณาลองอีกครั้ง
โลโก้ Freelancer Thailand / ภาษาไทย ช่วยเหลือและสนับสนุน FreelancerประเภทโปรเจคการประกวดFreelancerองค์กรแพ็กเกจสมาชิกโครงการ Freelancer ชั้นแนวหน้าการจัดการโปรเจคงานในพื้นที่Photo Anywhereหน้าจัดแสดงผลงานAPI สำหรับนักพัฒนาได้รับการยืนยันDesktop App เกี่ยวกับเกี่ยวกับเราวิธีใช้งานความปลอดภัยนักลงทุนแผนผังเว็บไซต์เรื่องราวข่าวออกสื่อทีมรางวัลข่าวประชาสัมพันธ์ร่วมงานกับเรา ข้อกำหนดนโยบายความเป็นส่วนตัวข้อกำหนดและเงื่อนไขนโยบายลิขสิทธิ์ข้อพึงปฏิบัติค่าธรรมเนียมและค่าบริการหุ้นส่วนEscrow.comLoadshiftWarrior Forum แอปโลโก้ Apple App Store โลโก้ Google Play
ไม่สามารถคัดลอกไปยังคลิปบอร์ดได้ โปรดลองอีกครั้งหลังปรับเปลี่ยนการอนุญาต
คัดลอกไปยังคลิปบอร์ดแล้ว
ผู้ใช้ที่ลงทะเบียน งานที่มีการโพสต์ทั้งหมด
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
กำลังโหลดตัวอย่าง
ได้รับอนุญาตสำหรับตำแหน่งทางภูมิศาสตร์
เซสชั่นการเข้าสู่ระบบของคุณหมดอายุและคุณได้ออกจากระบบแล้ว กรุณาเข้าสู่ระบบอีกครั้ง