}


my problem is that, as long as the $_POST['strap_city'] array exists, "lee county" ends up checked. i'm pretty sure it's because $code for "lee county" is zero. i've tried writing this conditional every way i can think of, but the damned thing keeps ending up selected. any suggestion on how i can get "lee county" checked only when a 0 is actually in the array?

Source: http://community.livejournal.com/php/549489.html

  • Function Help needed.

    Date: 03/08/07     Keywords: php

    I use an old function tossed together by a friend to replace {VARIABLES} in that format in a file like "filename.tmpl" so something like "This is a {VARIABLE}" might output as "This is a test". He used two functions to accomplish this - and I'm trying to condense it into one but I'm running into an error.

    Here is the old code and method of execution:

    function loadtemplate($tmpl) {
    $fp = "$_SERVER[DOCUMENT_ROOT]${tmpl}";
    $loadtemplate = file_get_contents($fp);
    return $loadtemplate;
    }

    function replace_tags($content,$vars) {
    while (list($key,$value) = each($vars)) {
    $key = '{'.$key.'}';
    $content = str_replace("$key","$value",$content);
    }
    return $content;
    }

    echo replace_tags(loadtemplate("test.tmpl"), array(
    'VARIABLE' => "Test"
    ));


    And here is my sleepily modified version:

    function contentManager($template, $content, $variables) {
    $loadFiles = "$_SERVER[DOCUMENT_ROOT]${template}";
    $loadTemplate = file_get_contents($loadFiles);
    return $loadTemplate;

    while (list($key, $value) = each($variables)) {
    $key = '{' . $key . '}';
    $content = str_replace($key, $value, $content);
    }

    return $content;

    }

    echo contentManager("test.tmpl", array(
    'VARIABLE' => "Test"
    ));


    For this - I get an error of: "Warning: Missing argument 3 for contentManager(), called in //Sites/new_function.php on line 21 and defined in /Sites/new_function.php on line 5"

    I'm pretty sure this is a really dumb error that I'm missing from sheer eye fatigue - but if someone could help me out I'd be grateful.

    Source: http://community.livejournal.com/php/549371.html

  • Pagination

    Date: 03/07/07     Keywords: database

    Hi

    I am working with a database where when users search they are only given the first 500 records (or however many fit their search criteria should it be less than 500). I want to have pagination set up so that there are 50 records per page. I used the tutorial found here however when I go from page to page using the "Next" or "Previous" links (or any of the other ones) it searches without the WHERE clause - the select statement being used reverts to "SELECT * FROM tablename LIMIT 0,50". You can see it in action at http://www.a5data.com/demo/ .

    I of course want it to remain "SELECT * FROM tablename WHERE [whereclause info]" with the pagination as well as the 500 records limit. Is this possible? If so, how would I go about doing it?

    Any help to solve this would be greatly appreciated as I'm banging my head against the wall trying to get this fixed.

    Thanks!

    Source: http://community.livejournal.com/php/548918.html

  • pHp newbie

    Date: 03/07/07     Keywords: php, mysql, css, html, database, sql, web, microsoft

    I have to make an online volunteer hour logger for a school project, so I've been teaching myself PHP for the past few days, but for some reason none of the scripts I've tried have worked for me. I have a domain and server that provide MySQL and a web-based database manager (CPanel) and know HTML and CSS pretty well.

    Basically what I want my website to be able to do is:

    1. Enable users to register (fields: name, student no., password, password verification, email)
    2. Login and submit their volunteering information in a form (fields: organization name, event/activity, volunteer type (drop down), date, #hours, reference letter (check box))
    3. Be able to edit this information after submission
    4. Logout
    5. Possibly the administration being able to access a report summarizing a certain user's information? (like a query on Microsoft Access)

    I've been following: http://www.tutorialized.com/tutorial/Signup-and-Login/3027 but after doing everything I don't know how to connect users to members-only pages.

    My website right now is: http://www.rhscolts.org/cas
    Login will be registration and login, and Your Hours will have a "Please login or register" message unless the person is already logged in, in which case the form and their volunteering info will appear.

    Is this too hard to do? Because I asked some people before I set about doing this project and they told me all I need is a few scripts, but then nothing is really working right now :(

    Can anyone help me please?
    My email is sheatore@hotmail.com if you want to talk to me directly.
    Please and thank you in advance, ANYONE!

    Source: http://community.livejournal.com/php/548674.html

  • PHP & Image Conversion

    Date: 03/05/07     Keywords: php

    Along the lines of the same program my boss has asked for - he threw image conversion into the mix. Specifically he wants to use PHP to generate thumbnails from the following formats:

    JPEG, GIF, PNG (not a problem) ... TIFF, PDF, EPS, AI, PUB

    Now - I've been googling and getting a lot of "Go use ImageMagick" but honestly - neither myself nor my boss wants to go that option, and are prepared to just suffer with the first 3 options. Do any of you know of an a way to have PHP create an image from those other formats (particularly PDF) that can be accessed a little more simply, like the simple "imagecreatefrom" built-in functions?

    Source: http://community.livejournal.com/php/548532.html

  • AJAX ajax AJAX

    Date: 03/05/07     Keywords: google

    Please don't run away because of the title. I'm working on a template which would include a sidebar with the ability to leave comments without refreshing...hence the AJAX implication.

    Now, the big issue at hand is I have NO knowledge on how to do this. Here is the template I'm working with. ( clicky )

    On the right you'll see the comment box, and above is a small bg image which looks like a quote bubble. So I want the submissions to appear over the bubble. And here is the catch, only three comments are to be allowed on the page. It needs to auto delete any (older) comments beyond 3. And a maximum of 100 characters per submission.

    IS THIS POSSIBLE?

    Of course it is. But I don't know how to do it. I've googled and ... damn it's a big world out there.

    Suggestions or offers?




    EDIT: Link fixed.

    Source: http://community.livejournal.com/php/548116.html

  • PHP/HTML to PDF

    Date: 03/05/07     Keywords: php, html

    hello y'all

    i need to convert html(php actually) to multi-page PDF files.

    ive tried FPDF but that also shows your HTML tags.

    anyone got any tips ?

    Source: http://community.livejournal.com/php/548065.html

  • Percentile

    Date: 03/05/07     Keywords: php

    Is there a built-in PHP function which returns the percentile of a range of numbers? 

    Source: http://community.livejournal.com/php/547789.html

  • File Upload Progress Bar

    Date: 03/05/07     Keywords: php, google

    My boss wants me to create an upload script that shows a progress bar of % uploaded - which is something I've never attempted in PHP. My initial Google searches suggests that PHP is limited in such a way that this cannot be done via PHP alone, and that a Perl/AJAX method is preferred.

    Now - I have little Perl and no AJAX experience, so I was just wondering if someone could comment on this. Is there a PHP method? Have any of you used a Perl/AJAX method or another to get something similar accomplished, and what was it?

    Source: http://community.livejournal.com/php/547497.html

  • Quick question.

    Date: 03/04/07     Keywords: php, mysql, html, database, asp, sql, web, yahoo

    Okay, I'm still getting the grasp of php... I went off for a while to actually learn html... Okay, well. I'm having the most troubles with mysql. It's quite confusing, along with cookies. Anyways, this isn't going to be about cookies. I want to just know how I can somehow get a nice list of... everything. Somehow. I really want know what's IN my mysql database and what names, etc. I'm using a pre-made script, so I'm rummaging around in circles with no straight answers on what what is.

    Anyways, I'm going to go to sleep, tomorrow I'll check back for answers for this... I'd like to know if I need to make a page or something like... www.website.com/mysqltestpage.php and go there.


    Eh. Anyways, I need a lot of advise, if someone has msn/yahoo/aim/irc/skype/etc. uhhh tell me if you'd let me add you and ask questions from time to time.

    Source: http://community.livejournal.com/php/547218.html

  • stars

    Date: 03/03/07     Keywords: php, database

    I'm trying to edit this star rating system...
    http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/

    I've got it working as it should, it wasn't that hard. Now I want to edit it to mesh into my site.

    This is what actually makes the stars show up on the page.. rating_bar('1',5);
    The 1 is the row on the database and the 5 is how many stars you want, easy enough.

    However, I want the 1 to change ... rating_bar('$x',5); Doesn't work.

    I'd like http://www.site.com/gallery.php?id=30 to do rating_bar('30',5);


    Help! Thanks.

    Source: http://community.livejournal.com/php/546936.html

  • Forms--All In One

    Date: 03/01/07     Keywords: php, html

    Is there any reason NOT to combine all the elements of a (blank) form with its verification scheme and resulting output in the same PHP file?

    I’ve been creating a form that submits to a secondary page to sanitize the input and verify specific fields before generating output html. 

    But this seems like a clunky novice approach begging for improvement.  I was thinking I should throw in a switch and combine all the elements into the same PHP file.

    I’d appreciate any thoughts you might have!

    Source: http://community.livejournal.com/php/546727.html

  • XML cms

    Date: 02/26/07     Keywords: cms, xml

    Hi every one just wonder if some one know good XML cms ?

    Source: http://community.livejournal.com/php/546457.html

  • blog with tags.

    Date: 02/26/07     Keywords: database

    As per my previous post I’m making a very simple blog. I'd like to include tags as a feature.
    I'm having trouble understanding the logic behind...

    The way I see it I'll need 2 or more tables in my database. One to handle the posts and one to handle the tags. In the post table I’d have an ID, subject, body, time, who posted it. For the tags table I’d have an ID, and tag field. Am I correct so far?
    I lose it at this point because now, what if someone tags with 'My Vacation to Mexico' and not Vacation, Mexico, Fun. The tag field in my tags table will be unable to sort by Mexico in the first example, or I'll get a bunch of crap data and be able to sort by the word My.

    Thoughts Ideas?


    Thanks.

    Source: http://community.livejournal.com/php/546150.html

  • double posts

    Date: 02/26/07     Keywords: browser, web

    I'm making a very simple "blog". It's more a post comments and view section for a website.

    My question is how do I prevent double posts when someone 'posts' then hits the back browser button?


    Thanks!

    Source: http://community.livejournal.com/php/546042.html

  • Site Search Engine

    Date: 02/25/07     Keywords: php, rss, xml, web

    I was wondering if there is a good place to use a php
    site search engine that will search your web site.
    I found a grep one and put it here:
    http://www.cardeologist.com/search.php
    but, it will show some files I don't want it to, like my
    sitemap.xml and my rss file, robots.txt file, etc.
    Is there a better one or a way to disallow files?
    And if I wanted to add subdomains, can I do that?




    Search cardelogist.com:





    " method="post">
    value="" size="20"
    maxlength="30"/>



    if (! empty($searchstr)) {
    // empty() is used to check if we've any search string.
    // If we do, call grep and display the results.
    echo '

    ';
    // Call grep with case-insensitive search mode on all files
    $cmdstr = "grep -i $searchstr *";
    $fp = popen($cmdstr, 'r'); // open the output of command as a pipe
    $myresult = array(); // to hold my search results
    while ($buffer = fgetss($fp, 4096)) {
    // grep returns in the format
    // filename: line
    // So, we use split() to split the data
    list($fname, $fline) = split(':', $buffer, 2);
    // we take only the first hit per file
    if (! defined($myresult[$fname])) {
    $myresult[$fname] = $fline;
    }
    }
    // we have results in a hash. lets walk through it and print it
    if (count($myresult)) {
    echo '

      ';
      while (list($fname, $fline) = each ($myresult)) {
      echo "
    1. $fname : $fline
    2. \n";
      }
      echo '

    ';
    } else {
    // no hits
    echo "Sorry. Search on $searchstr
    returned no results.
    \n";
    }
    pclose($fp);
    }
    ?>

    Source: http://community.livejournal.com/php/545756.html

    1. More on PECL / imagick wrapper.

      Date: 03/10/07     Keywords: php

      So I've got Image Magick and the pecl 'imagick' wrapper installed on my home computer (a Mac running 10.4.8) and on our work server (some flavor of *nix, not sure). I've been testing a sample script on both ends and have run into a dilemma.

      The server has no trouble converting Adobe Illustrator (.ai) or Adobe Acrobat (.pdf) files to other formats; but my home computer returns:

      Warning: imagick_iserror() expects parameter 1 to be resource, boolean given in /path/to/my/file


      I'm not sure what the issue is so let me provide just a few more potentially helpful tidbits.

      Both systems are using PHP v5.2.1 - here is the imgaick configuration (as obtained from phpinfo(); for the server:

      ImageMagick support		enabled
      Magick Backend	 		ImageMagick
      ImageMagick version 		6.0.7
      PHP imagick version 		0.9.11
      MaxRGB 				65535
      Supported image formats 	tmp
      Font Family - Name 		(null) - (null)


      And here is the configuration for my home system.

      ImageMagick support		enabled
      Magick Backend			ImageMagick
      ImageMagick version		6.3.3
      PHP imagick version		0.9.11
      MaxRGB				65535
      Supported image formats 	clipmask
      Font Family - Name		helvetica - fixed


      If anyone has some thoughts on how to remedy this I'd appreciate it. I've read rumors that ImageMagick 6.x is unstable with the PECL imagick wrapper - but I haven't found anything conclusive. I'm also a little unsure of how to revert to a lower version (if it's just as simple as overinstalling, etc.)

      Thanks in advance.

      Source: http://community.livejournal.com/php/550861.html

    2. session errors

      Date: 03/09/07     Keywords: php

      I just switched hosts and now I'm getting these error messages, on every page.


      Warning: Unknown(): open(/tmp/php-ses/sess_f7efe480a375ea32d0467d87eaafe5b5, O_RDWR) failed: Permission denied (13) in Unknown on line 0

      Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp/php-ses) in Unknown on line 0


      Does anyone have an idea?


      Thanks.

      Source: http://community.livejournal.com/php/550200.html

    3. PECL imagick on OS X

      Date: 03/08/07     Keywords: php

      Recently I went through the adventure of installing ImageMagick and all of its dependencies on a system running OS X 10.4.8. Now I'd like to install the PECL imagick wrapper (http://pecl.php.net/package/imagick) but I'm at a total loss for how to go about this, even after reading the install directions.


      Edit: I can get the latest PECL build to go through all the motions now... configure, make, make install, etc. But I cannot get PHP to recognize that it's installed. So any help specific to that would be a godsend.

      Source: http://community.livejournal.com/php/549924.html

    4. Weird PHP + MySQL resource error

      Date: 03/08/07     Keywords: php, mysql, sql, google

      Using PHP 5.2.1 on a windows command (cli) environment I ran into a really weird bug about two days ago. Using xdebug to step through my code, the 'mysql link' resource becomes partially corrupted. What I mean is: it's still a resource, it still has the same id #, but the type shifts to 'Unknown'. I've run extensive searches through the code for all mention of the link resource variable but the only assignment is when it's set with mysql_connect(). This passed through pretty much every safety check (! null, is_resource, isset() ) and into mysql_ library functions. So I kept getting warnings saying to the effect '15 is not a valid mysql link resource' that then cascaded into errors about 1000 ticks afterwards.


      So my question, has anyone heard of this happening, I've rummaged through php.net bugzilla and also googled, but have come up empty.

      Pre-answers: the entire environment is dedicated to this script
      php.ini: all mysql limits are set to -1.
      The script is a daily cronscript.
      At ramp up, the script balloons to 192MB-240MB and 99.9% cpu utilization for the entire duration of the script which is fine because this all will be running on a dedicated machine that will be running idle when this thing executes.


      The solution I came up with, is that when mysql_real_escape_string returns false, unset the resource, then reassign it from mysql_connect() then try 1 more time before throwing an exception.

      Source: http://community.livejournal.com/php/549713.html

    5. false positive with in_array and 0

      Date: 03/08/07     Keywords: no keywords

      i have a form with an array of checkboxes. after a query is submitted, the page refreshes with the form filled in per the users' choices. the array of checkboxes is created with the following relevant snippets:


      $cities = array('B' => 'bonita springs',
                      'C' => 'cape coral',
              'P' => 'fort myers',
              'W' => 'fort myers bch',
              'T' => 'sanibel',
              '0' => 'lee county'
                  );


      [...]

      foreach ($cities as $code=>$city) {
                   ?>
                   

                                            />
                             
                 
    Previous page  ||  Next page


    antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home