www.webdeveloper.com
Results 1 to 10 of 10

Thread: Mulitple Quotes Problem

  1. #1
    Join Date
    Jun 2005
    Posts
    5

    Mulitple Quotes Problem

    I need to echo this code:
    PHP Code:
    $linkDay=>array('#','style',"MM_openBrWindow('page.php?id=".$row_recordset['id']."','Green','scrollbars=yes,width="300",height="500"')",NULL.$linkDay), 
    But when i place it in quotes for the echo, they cancel eachother out, like this:
    PHP Code:
    echo "$linkDay=>array('#','style',"MM_openBrWindow('page.php?id=".$row_recordset['id']."','Green','scrollbars=yes,width="300",height="500"')",NULL.$linkDay)," 
    Any suggestions?

  2. #2
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    linkDay=>array('#','style',"MM_openBrWindow('page.php?id=".$row_recordset['id']."','Green','scrollbars=yes,width=\"300\",height=\"500\"')",NULL.$linkDay),
    Stephen

  3. #3
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    to echo the array out you should use a foreach loop

    kinda like...
    PHP Code:
    foreach($linkDay as $value) {
    echo 
    "$value <br>\n";


  4. #4
    Join Date
    Jun 2005
    Posts
    5
    Ok now I am running into another problem so I'll just see if there is a better way of doing this. Here is what I am trying to do. I am trying to have the following code and repeat one line of it. Here is what I have so far but it obviously dosent work:
    PHP Code:
    $days = array($today=>array(NULL,'calendar-day',NULL,NULL.$today.'</span>'),
    do { 
    $linkDay=>array('#','calendar-linked',"MM_openBrWindow('detailAppearances.php?id=".$row_rsAppearances['id']."','Green','scrollbars=yes,width=".$row_rsPage['winWidth'].",height=".$row_rsPage['winHeight']."')",NULL.$linkDay.'</a>'),
    } while (
    $row_rsAppearances mysql_fetch_assoc($rsAppearances));
    ); 
    And I get this:
    Parse error: parse error, unexpected T_DO, expecting ')'
    So I tried to fix it by wrapping some of it in quotes and using echo, then the repeat function worked but instead of the code being repeated it was displayed as literal text.

  5. #5
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    Quote Originally Posted by wkrauss
    Ok now I am running into another problem so I'll just see if there is a better way of doing this. Here is what I am trying to do. I am trying to have the following code and repeat one line of it. Here is what I have so far but it obviously dosent work:
    PHP Code:
    $days = array($today=>array(NULL,'calendar-day',NULL,NULL.$today.'</span>'),
    do { 
    $linkDay=>array('#','calendar-linked',"MM_openBrWindow('detailAppearances.php?id=".$row_rsAppearances['id']."','Green','scrollbars=yes,width=".$row_rsPage['winWidth'].",height=".$row_rsPage['winHeight']."')",NULL.$linkDay.'</a>'),
    } while (
    $row_rsAppearances mysql_fetch_assoc($rsAppearances));
    ); 
    And I get this:
    So I tried to fix it by wrapping some of it in quotes and using echo, then the repeat function worked but instead of the code being repeated it was displayed as literal text.
    In your code there you are missing a ) as the error says...

    It should be
    PHP Code:
     $days = array($today=>array(NULL,'calendar-day',NULL,NULL.$today.'</span>')), 

  6. #6
    Join Date
    Mar 2004
    Posts
    3,056
    A quick tip for testing is to use var_dump($array_variable); to see the contents of the array at a glance. Just stick it between <pre> tags of html to make it more readable. You can do it with any kind of variable, but it's particularly handy on arrays and multi dimensional arrays.

  7. #7
    Join Date
    Jun 2005
    Posts
    5
    Actually BeachSide, thats not the problem, its that it wasn't expecting the do while loop where it was but was expecting the rest of the array, so it endede at the do part. But, I still need a way to repeat that one line of code between the do and while. When I enclosed everything in quotes and used an echo, the code worked but was displayed as visual text on the website instead of the code it should be. I need some more effective way to loop that line of code. ARG. Thanks for the input so far, its kinda helping...

  8. #8
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    No matter what you needed that ) to close the thing.

    Also I was looking at that earlier and was wondering why you have a do-while loop you don't really need it, just do a while loop...

    but as I look at it more what is it you are trying to accomplish by having that array in the first place? Can't you put the data from the db into the array and plug it into the string you want to echo out?

    also in that muti dimensional array you have shouldn't you be calling $today by reference like this &$today
    Last edited by BeachSide; 06-09-2005 at 03:43 AM.

  9. #9
    Join Date
    Jun 2005
    Posts
    5
    That script I am using is part of a clanedar script. I will display a visual callendar and the line I am trying to get repeat would link create a link in the calendar for teh corresponding day in the database, but I cannot get it to repeat so all that works right now is if I replace the $linkDay with a number, lets say 15, then on the callendar the 15th would become linked to that page I have specified in the array (the MM_openBrWindow). The origional script can be found at www.keithdevens.com/software/php_calendar I have just manipulated it to do waht I need, and everything I have changed so far works except for this one part.

  10. #10
    Join Date
    Feb 2005
    Location
    BC, Canada
    Posts
    1,098
    I would suggest just a while loop. Do.while isn't nessecary, and is harder to work with (in my opinion).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles