"; for ($a = 0; $a < 5; $a++): echo ""; endfor; print ""; endfor;

currently just loops the first set of 5 records returned based on the number of rows used. Is there a way for this to actually return the proper results with the right loopthrough (e.g. 2nd runthrough by for() returns the 2nd set of 5 results)?

EDIT: Solved;

for ($a = 0; $a < 5; $a++):
	$num = $i*5+$a;
	echo "
"; endfor;

fixed everything. Thanks '[info]'olithered!

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

  • Serving files to users…

    Date: 06/16/06     Keywords: php

    Background:  Smallish, private, and login protected site that serves files to users directly, and generic files delivered based on membership options. (some files contain personal content)

    Question:  What method of serving the files to the user would you suggest?

    Right now I bring up a dynamic form that lists the files, each with a button for downloading/viewing.

    The form is probably stupid, and I’ve thought of sending information through the url to a php file for processing and posting.

    Suggestions?  (narrow or broad, I welcome them all)

    BTW—You folks make me smarter, and I appreciate all the past help.

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

  • CakePHP Community

    Date: 06/14/06     Keywords: php, security

    For anyone intersted I just started up a CakePHP community ('[info]'cakephp) as an alternate means to their IRC channel for getting community help

    i've heard strong arguments for and against Cake (and for and against MVC frameworks), but i've definitely had a good experience with it so far, and it's really helping to bring my coding up out of the amateur level and i'm more confident in the security and stability of the apps I'm building with it

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

  • quick questions

    Date: 06/14/06     Keywords: php

    I'm somewhat of a novice with php. I have a script that simply writes a string to a file. But if the string contains " or ' it changes it to \" or \' onee stored in the file (I'm sure it does it to other special characters as well). How can I prevent this?

    P.S. I'm using file_put_contents() [php 5 only]. Would it be better to use fopen(), fwrite(), and fclose()?

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

  • crack base64 encoding?

    Date: 06/12/06     Keywords: php

    Bought a PHP script that I thought was going to save me time. Ugh. Even with correct configuration, no luck even connecting to db. But the worst part is that I have the code but it's base64 encoded. Anyone have suggestions for cracking or reverse engineering? I see in the source eval(base64_decode(...)) procedures that begin the script. The reaminder of that source is in that script but it's encoded out of PHP tags so I don't know what's going on. Is it even possible to decode?

    I wouldn't be in such pursuit to crack it if the developer had any integrity to respond to these issues but at this point, cracking seems to be my only hope. Where does one go? Any suggestions?

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

  • Finding item in an array

    Date: 06/12/06     Keywords: no keywords

    Hi, I have a complaex array returned from the API

       [0] => Array
            (
                [0] => 1
                [ID] => 1
                [1] => Dave
                [Name] => Dave
                [2] => US English (Male)
                [Language] => US English (Male)
            )
    
        [1] => Array
            (
                [0] => 2
                [ID] => 2
                [1] => Susan
                [Name] => Susan
                [2] => US English (Female)
                [Language] => US English (Female)
            )
    

    From another function I am given a value such as "Dave", and I have to find and use the value for the ID (For Dave it would be 1)

    This doesnt seem to work:

    $key = array_search("Dave", $array);
    $id = $array[$key][ID];


    Any idea how to do this?

    SOLVED
    foreach ($array as $key => $sub_array) 
    	{
    		if (array_search('Dave', $sub_array, true))
    			{
    			$voice_id = $key;
    			}
        }
    $id = $array[$voice_id]['ID'];
    

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

  • Sanitizing user data for database usage

    Date: 06/09/06     Keywords: mysql, sql

    I know it's an age-old question, but I just wanted your opinions on it: How should I be santizing my data before using it in my MySQL queries so as to prevent against nasties like SQL injection attacks?

    At the moment I'm using the function below - is this sufficient?

    Thanks in advance. :)


    /*
    safeVar Function
    Rids variables of nasty characters


    $var = safeVar ($var);

    */
    function safeVar ($value) {
    // stripslashes
    if (get_magic_quotes_gpc ()) {
    $value = stripslashes ($value);
    }

    // Quote if not integer
    if (!is_numeric ($value)) {
    $value = "'" . mysql_real_escape_string ($value) . "'";
    }

    return $value;
    }

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

  • Matching a variable against several options

    Date: 06/08/06     Keywords: php, mysql, sql

    In MySQL there is a way to do this:

    SELECT something FROM tablename WHERE something IN (2,3,4,5,6);


    Is there a way to do the same with PHP (the logic, not the query)?

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

  • PHP Book

    Date: 06/07/06     Keywords: php, programming, mysql, sql, linux, apache

    Hello Friends

    I am a programmer in a Linux/Apache/MySQL/PHP shop. I also do some Windows programming in Delphi and have done lots of other stuff academically.

    I'm looking for a book on PHP that will help me with "bigger picture" and "higher level" design considerations. I'm looking for a book that contains complete solutions and ideas for solving medium to large problems. Object-oriented designs are a big plus.

    I'm also looking for a great reference manual.

    I've been poking around looking at reviews, but I would like to have the opinions of some serious PHP programmers first.

    Thank you!

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

  • cyrillic characters

    Date: 06/06/06     Keywords: mysql, database, sql

    this has been driving me mad for several hours now :(

    how on earth do I convert cyrillic characters into something that can be safely stored and retrieved from a mysql database?

    From playing around with wordpress etc, I know I need to do this:

    привет -> привет

    but I have no idea what function(s) to use. Thanks :)

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

  • domxml functions not recognized

    Date: 06/06/06     Keywords: php, xml

    First time on this server, last night I tried

    $doc = domxml_new_doc()

    Got a function undefined error. Apparently domxml isn't installed by default on PHP 5? I thought it was.

    I did phpinfo and I do lave libxml2 installed, it also says that XML is enabled. But what was really wierd is that no configure command came up on phpinfo. Is everything handled through php.ini on PHP 5??? Me confused. Nowhere could I find a file that has my install configuration.

    Give me the tools and I can code, make me install this crap and I get the urge to go out and kill a penguin. Grrr.

    Any ideas?

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

  • Good Beginners PHP Book?

    Date: 06/03/06     Keywords: php

    Can anyone suggest a good 'beginners' PHP Book? Preferably one that allows you to learn in stages.

    Thanks in advance for your help and/or suggestions.


    Cheers!

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

  • PHP and .htaccess

    Date: 06/02/06     Keywords: php

    I know .htaccess can be used to protect contents of a directory from being publically viewed (images for instance). But how or can php be used to give a user temporary access to a single file to view through a script? I searched for .htaccess on php.net but couldn't find any decent info on the subject.

    Anyone ever dealt with this before?

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

  • I want to open a new window with content I pass through the URL link.

    Date: 06/02/06     Keywords: php, browser, java

    I’m passing variables through the URL, to determine the content of a dynamic (php) page.

    But I’d like to open this URL in a new browser window with specific height and width settings.

    I know how to open a new window with those settings using javascript….

    But I don’t know how to do both --  pass the variables AND use the javascript.


    Can anyone point me in the right direction?

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

    1. mysql_connect woes

      Date: 06/23/06     Keywords: php, mysql, asp, sql

      I have a very simple script set up to verify weither or not I can connect to mySQL from a PHP script.

      <?php
      $link = mysql_connect('localhost', 'root', 'XXXXXXXX');
      if (!$link) {
      die('Could not connect: ' . mysql_error());
      }
      echo 'Connected successfully';
      mysql_close($link);
      ?>

      I recieve the following error:

      Could not connect: Can't connect to local MySQL server through socket '/var/mysql/tmp/mysql.sock' (13)


      I tried replacing 'localhost' with 127.0.0.1 .

      Now I have a completely different error message:

      Could not connect: Lost connection to MySQL server during query


      First of all I'd like to know why I can't just use 'localhost' and second, I'd like to get this damn thing to work! I'm really frustrated. I hope someone can help. I've searched all over the internet for a solution to my problem but am having no luck. mySQL is running fine, and the mysql.sock file is there where it should be. I can also log in from the command line. I am exasperated!


      I am running Slackware 10, mySQL 5.0.21-log, and PHP 4.4.2.


      Any ideas helping me out would be much appreciated. I need this to work!

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

    2. iFrame PHP

      Date: 06/23/06     Keywords: php

      Hey guys,

      I'm redesigning my site, and I'm pulling up a bunch of different pages into iFrames.

      Is there a PHP script I can put in these external files, so if some one links to them, it calls up the main page with the iFrames?

      I hope that makes sense.

      thanks

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

    3. Awstats Install

      Date: 06/22/06     Keywords: php, linux

      I have a linux server running Fedora Core 3, and for some reason cant seem to get round the install instructions for awstats, has anyone done this? is there an idiots guide? do you install a version for every site or is there config files which can be called by script?

      Any help would be appreciated, it's probably really simple, but you know how it is 1000 projects and nothing makes sense anymore.. or I'm just stupid which is also a possibility :)

      [Edito: I think I cracked it using http://forums.hostrocket.com/showthread.php?t=17248 however I'm not sure if its using the log file for the right site on the server, but then again, that's not something y'all can help with now is it :P]

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

    4. file editing

      Date: 06/22/06     Keywords: php, html

      Is there a simple way (or is there code out there now) that can allow me to edit a (local) html page? I have a file upload page working, but I now want to be able to update links on a separate page that is on the same server (same folder) so that there is a link to the file.

      I once did this on python but that box died a horrible death a year or two ago and naturally I do not have any backups). I was able to open a file, look for a specific string like <###REPLACEME###> and then stick what I needed in front of it. Can this be done in php?

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

    5. Files vs. Databases

      Date: 06/20/06     Keywords: php, database, java

      I have a question about which is more expensive: writing to a file, or saving to a database. We're talking about an average of 450 characters (when the array is serialized). The usage is always read frequent, but it varies between write frequent and write infrequent.

      The PHP script is an interface for a couple people, connected via AJAX. The script gets called oncy every 5 seconds (by each person via JavaScript) to make sure they're all on the same page. Right now I'm using the filesystem - I know that, should by some miracle I get more servers in the future, using files won't be an option. But, right now I'm on one and probably staying on only one.

      I want to know where to save this information. What is worse - running file_get_contents() and unserialize() every 5 seconds, or calling a database every 5 seconds? I've heard bad things about both, and I'm wondering what your opinions are.

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

    6. someone help me please??

      Date: 06/19/06     Keywords: no keywords

      OK I wasn't sure about asking here as the script isn't mine but I really need someone's brain to help me! (and no I don't know the original script writer)

      Anyway I have a xmb forum and I have this scrip that can show a feed of like the top ten newly posted threads and all that! The thing is it shows my passworded sub forum which is for over 18 year olds only and I don't want the threads in it to be shown!

      If anyone can help I'll be very greatfull since the people i've asked for help haven't

      This is the script (I put it in a text file I hope that is ok as it's pretty big)

      Anyway if you need anymore info or anything then just say so I'll be happy to help

      thanks

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

    7. for loop question

      Date: 06/18/06     Keywords: no keywords

      Ok, I'm writing a script that reads out values from a text file and prints 5 per row. What I've currently got:

      $patches = array();
      while(!feof($fp)):
      	$patch = fgetcsv($fp, 4096);
      	
      	for ($i = 0; $i < 1; $i++):
      		$patches[] = $patch[0];
      	endfor;
      endwhile;
      
      // let's now loop for every 5 records
      
      $numpatch = count($patches);
      $numpatch = ceil($numpatch/5);
      
      for ($i = 0; $i < $numpatch; $i++):
      	print "
    $patches[$a]
    $patches[$num]
    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