SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    819
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Str_Replace Not Replace txt

    Greetings!

    I'm trying to replace some text with the use of str_replace and I'm not having any luck. I've looked at past postings and tried different combos and still can't get it to work. There are no error messages; the word just simply won't change to the new one.

    PHP Code:
    mysql_select_db($database_rcofcuser$rcofcuser);
    $query_getCalendar "SELECT * FROM chamber_calendar, months WHERE chamber_calendar.month_id = months.month_id ORDER BY chamber_calendar.year, months.month_id";
    $getCalendar mysql_query($query_getCalendar$rcofcuser) or die(mysql_error());
    $row_getCalendar mysql_fetch_assoc($getCalendar);
    $totalRows_getCalendar mysql_num_rows($getCalendar);

    $phrase "Ripon Chamber of Commerce presents the 27th Annual Main Street Day and Car Show in downtown Ripon on Saturday, October 15, 2011 starting at 9:00am to 3:00pm.";
    $oldWord "Car Show";
    $newWord "Car Shows";
    $row_getCalendar str_replace($oldWord$newWord$row_getCalendar); 

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    $row_getCalendar is not a string, it's an array. So you want to replace that string in all components of that array?

  3. #3
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by toad78 View Post
    PHP Code:
    $row_getCalendar mysql_fetch_assoc($getCalendar);

    $phrase "Ripon Chamber of Commerce presents the 27th Annual Main Street Day and Car Show in downtown Ripon on Saturday, October 15, 2011 starting at 9:00am to 3:00pm.";
    $oldWord "Car Show";
    $newWord "Car Shows";
    $row_getCalendar str_replace($oldWord$newWord$row_getCalendar); 
    that doesn't make too much sense to me.
    didn't you want to write something like
    PHP Code:
    $phrase "Ripon Chamber of Commerce presents the 27th Annual Main  Street Day and Car Show in downtown Ripon on Saturday, October 15, 2011  starting at 9:00am to 3:00pm.";
    $oldWord "Car Show";
    $newWord "Car Shows";
    $result str_replace($oldWord$newWord$phrase); 
    or what should that $phrase be good for?
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  4. #4
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    819
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    $row_getCalendar is not a string, it's an array. So you want to replace that string in all components of that array?
    You know, you're right, StarLion. That is an array. I'm just trying to replace 'Car Show' words with a different set of words but keep getting some oddball characters and not the affect I want.

    I've changed it to this and still can't get it right, apparently:
    PHP Code:
    $row_getCalendar str_replace("Car Show""Car Shows"$row_getCalendar); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •