Jump to content

php4ever

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Posts posted by php4ever

  1. I posted it here;

    http://livedemosite.com/fixcsv/testing_full.php

     

    If you run the script, it just duplicates the output in a loop of some sort.

     

    The idea behind the above script is to take that nasty CSV file and fix the text data by removing all those extra breaks and html code.  I know it now works properly for formatting because looking at the 2 left columns I see the main ID and the secondary ID consistently.

     

    What doesn't work, is it keeps looping. You can for instance open your FireFox, hit CTRL+F and search for 3966497 and you will see that the output has been produced again and again. There are 200 rows in the CSV, none are the same.

  2. Ok here you go

    // the column-array.php is just the array matching that in the data.csv.
    require_once("column-array.php");
    $fp = fopen("data.csv", "r");
    
    // getZip not used this version
    function getZip($full)
    {
    $pieces = explode(' ', $full);
    $zip = explode('(', $pieces[count($pieces)-1]);
    $zip = explode(')', $zip[1]);
    return $zip[0];
    }
    
    $pre="";
    while (($data = fgets($fp,4096)) !== FALSE) 
    {
    $data=str_replace("\r\n","",$data);
    if(trim($data)=="" or substr($data,strlen($data)-1,1)!='"' or substr($data,strlen($data)-2,2)==',"')
    {
    	$pre.=$data;
    }
    else
    {
    	$data=$pre.$data;
    	$data=str_replace(array(',""','","','"',"'","html","\r\n"),array("","|","","","PHP"," "),$data);
    	$data=preg_replace("/\r|\n|\v|\r\n/smUi"," ",$data);
    	$data_elements=explode("|",$data);
    }
    ////////////////////////////////////////////////////////////////////////////
    // USED TO ECHO FIELD COLUMNS IN A TABLE - Used For Testing Output
    ////////////////////////////////////////////////////////////////////////////
    echo("<table border=2 cellpadding=5 cellspacing=5>");
    $i++;
    echo("<tr>");		
    foreach($data_elements as $k)
    {
    echo("<td valign=top width='20' style='overflow:hidden;'>");
    echo($k);
    echo("</td>");
    }
    echo("</tr>");
    echo("</table>");
    continue;		
    $listings++;
    //}
    }
    fclose($fp);
    

  3. I have a script that opens up a CSV file and outputs to a table for testing. It ultimately inserts into a MySQL but the code below literally duplicates every third row consistently. I'm 95% sure its in the "WHILE" area.  Is there enough code here for someone to point out an error. If not I can put the code up live and if you want a fee for fixing just PM me please.

     


    $fp = fopen("residential-data.csv", "r");
    $listings=-1;
    function getZip($full)
    {
    $pieces = explode(' ', $full);
    $zip = explode('(', $pieces[count($pieces)-1]);
    $zip = explode(')', $zip[1]);
    return $zip[0];
    }
    
    $pre="";
    while (($data = fgets($fp,4096)) !== FALSE) 
    {
    $data=str_replace("\r\n","",$data);
    if(trim($data)=="" or substr($data,strlen($data)-1,1)!='"' or substr($data,strlen($data)-2,2)==',"')
    {
    	$pre.=$data;
    }
    

  4. Thats nice, it doesn't appear to allow me to redistribute the app I'm creating.

    If I have all the tables in an HTML, is it over complex to have someone just code this or is it rather involved?

  5. I have three small tables and I'm looking for a clean, light, framework CRUD generator that I can use.

    Are there any that are small and light that dont require a full blown install like Symphony or phpObject Generator etc...

     

    Jared

  6. With ACCESS or Jet databases that have a nice way to create joins and relationships making everything super lean is exceptionally easy to understand for the most part. With MySQL this would require a ton of PHP coding to keep them together when it comes to searches and such so I want to create all data in larger tables to accommodate more fields as opposed to breaking up each field element into multiple rows.

    Is this a better way to build such a DB.

     

    ID | Date | Expiration | TTD | LBC | (then) 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 etc and so on.

     

    In table 2 I would have

     

    1 Name

    2 City

    3 State

    4 Country

    5 Donation

    6 TaxID

     

    Does that seem like a logical way to make the DB extensible enough to change yet keep performance super tight?

     

     

  7. Yeah that unfortunately is not an option on this server. That was my first thought. Is there no way to redirect from one script to the next via SHELL. If not I can try and bury it somewhere its not visitor accessible.

     

  8. I'm using ob_start(); in a script as follows for redirect and I'm seeking an alternative that can work from the shell

     

    <?php

    ob_start();

     

    // MY Script here

     

    sleep(10);

    header ("Location: http://www.jaredritchey.com/project/testing/steptwo.php");

    ob_flush();

    ?>

     

    This works fine however when I move it to the root of my server there is no way to use the browser direct obviously but there must be an alternative.

     

    I could setup two CRONs but the problem is that the first script processes a CSV file and the size changes frequently so the time would also change.

     

    Any assistance is appreciated.

     

    THX, Jared.

     

     

  9. I have a text file that has about 2,000 rows of data. Unfortunately it also has column headers and my script will not skip the first row regardless of all my attempts.

     

     

       

    BUSOEMPS

       

    BUSOLSTR

       

    BUSOPRKG

     

     

       

    7

       

    No

       

    Yes

     

     

       

    3

       

    Yes

       

    No

     

     

       

    6

       

    Yes

       

    No

     

     

       

    0

       

    Yes

       

    Yes

     

     

       

    0

       

    No

       

    Yes

     

     

       

    7

       

    Yes

       

    Yes

     

     

       

    0

       

    No

       

    No

     

     

       

    0

       

    NO

       

    No

     

     

       

    0

       

    NO

       

    Yes

     

     

       

    0

       

    Yes

       

    Yes

     

     

       

    0

       

    No

       

    Yes

     

     

       

    0

       

    No

       

    Yes

     

     

       

    6

       

    Yes

       

    Yes

     

     

       

    0

       

    No

       

    Yes

     

     

    require_once('dbsettings.php');
    $sqltablepref = "set3_";
    
    $insert_fields=array(
    "BUSOEMPS"=>"0",
    "BUSOLSTR"=>"1",
    "BUSOPRKG"=>"2"
    );
    
    function explode_features($insert_fields_features, $features) {
       $elements = explode(",", $features);
       $newStr = "";
       $i=0;
       foreach ($elements as $field_element)
       {
       //echo($bit);
            if (array_key_exists($field_element,$insert_fields_features))
            {
            	if ($insert_fields_features[$field_element])
            		$newStr .= $insert_fields_features[$field_element].", ";
            }
       }
       return substr($newStr,0,-2);
    }
    $specified_user_id="";
    $sql="select userdb_id from ".$sqltablepref."userdb where userdb_user_name like 'Manager'";
    $select=mysql_query($sql);
    $rows=mysql_num_rows($select);
    if($rows==1)
    {
    $row=mysql_fetch_array($select);
    $specified_user_id=$row[0];
    }
    else
    $specified_user_id=2;
    $specified_id="";
    $select=mysql_query($sql);
    $rows=mysql_num_rows($select);
    if($rows==1)
    {
    $row=mysql_fetch_array($select);
    $specified_id=$row[0];
    }
    else
    $specified_id=2;
    $fp = fopen("business_list.csv", "r");
    while (($data = fgets($fp,4096)) !== FALSE) 
    {
    	$data=str_replace('","',"|",$data);
    	$data=str_replace('"',"",$data);
    	$data=str_replace("'","",$data);
    	$data_elements=explode("|",$data);
    
           // the data elements below are for user first name and last name which is field 45 and 49
    
    	$sql="select userdb_id from ".$sqltablepref."userdb where userdb_user_name like '".$data_elements[45].$data_elements[49]."'";
    	$select=mysql_query($sql);
    	$rows=mysql_num_rows($select);
    	$row=mysql_fetch_array($select);
    	if($rows==1)
    	{
    	continue;
    	}
    	$user_id=0;
    	$sql="select max(userdb_id) from ".$sqltablepref."userdb";
    	$select=mysql_query($sql);
    	while($row=mysql_fetch_array($select))
    	$user_id=$row[0]+1;
    	if(strlen($data_elements[45]) && strlen($data_elements[49]))
    	{
    	$sql= "INSERT INTO " . $myconfig['table_prefix'] . "userdb VALUES 
    			(".$user_id.",
    			'".$data_elements[45].$data_elements[49]."',
    			'".$data_elements[53]."',
    			'".$data_elements[45]."',
    			'".$data_elements[49]."',
    			'Contact Jared Ritchey For Details',
    			'no',
    			'no',
    			'no',
    			'no',
    			'no',
    			'no',
    			'2008-07-16',
    			'no',
    			'no',
    			'2008-07-16 11:20:49',
    			1,
    			'no',
    			'no',
    			'no',
    			'yes',
    			'no',
    			-1,
    			'no',
    			'no',
    			'no',
    			'no',
    			'no',
    			'no',
    			'no'
    			)";
    	mysql_query($sql);
    	$specified_user_id=0;
    	$sql="select userdb_id from ".$sqltablepref."userdb where userdb_user_name like '".$data_elements[45].$data_elements[49]."'";
    	$select=mysql_query($sql);
    	while($row=mysql_fetch_array($select))
    	$specified_user_id=$row[0];
    	foreach($agent_fields as $field=>$num)
    		{
    		$sql = "INSERT INTO  ".$sqltablepref."userdbelements SET
    			userdbelements_field_name = '".$field."',
    			userdbelements_field_value = '".$data_elements[$num]."',
    			userdb_id  =".$specified_user_id;
    		mysql_query($sql);
    		}
    	}
    }
    fclose($fp);
    echo("business directory added"."<br />"); 
    

     

    What happens is that when I run this script to update my directory it includes the very top row of the text file which is the column headers as a record. I dont want the top row included as a record.

  10. I'm trying to create a simple template version notification snippet and I'm missing something but what I'm not sure;

     

    <?php
    function version_check()
    {
    $template_version = '2.5';
    if (ini_get("allow_url_fopen") == 1) {
    	$lastest_version = @file_get_contents("http://www.jaredritchey.com/downloads/601.txt");
    	$check = version_compare($template_version, $lastest_version, ">=");
    }
    
    }
    echo($latest_version);
    ?>

     

    The idea is to look at a directory and compare versions.  If there is a newer one then echo a statement or something.  If not echo nothing.

     

    Is allow_url_fopen a down graded function or did I just approach this wrong?

     

    ~ Jared

  11. ####### PAID ########

     

    I paid a guy that vanished on me in a freelance forum so I thought I'd come where people have helped me for free in hopes of a coder.

     

    I need what I believe to be painfully simple for a coder but I make no assumptions.

     

    I need a way to have a web based script that will generate three user defined thumbnails in JPG or PNG format.

     

    Basically a person would browse to the PNG or JPG on his / her drive, set the three width sizes for the images, enter the file prefix and hit generate or start.  The output should be three images sized by width according to the user defined variables.

     

    I built a form and such to play with the look and basically its just a form where you set the width of each of the three images and a browse button.

     

    I hired a guy to modify the following scripts for consideration.

     

    http://phpthumb.sourceforge.net/ and I considered asking for him to modify the following depending on which ever was easier http://www.anyexample.com/programming/php/php_multiple_photo_thumbnail_generator.xml

     

    What would it cost and what do you need from me?

     

    ~ Jared

     

  12. I know I found it in these forums but I have looked for hours with no luck.

     

    I had a small PHP snippet that I could add to my application that would limit its working to the domain I put in the variable.  I'll be if I can't find it in these forums.  Could someone point it out if you happen to know where it is?

     

    I plan to put it in the header of a template and encrypt the header so it can be used to demo it only on a particular URL or domain.  I hope that clarifies which one I was after.

  13. Oh yeah, I tried like hell to get the line that is commented out to work and couldn't

     

    case "/jared/index.html" || $P == "/" || "$P" == "/jared/index.php":

     

    The idea is that if a person lands on the homepage without the file extension of either index.php or index.html they would still get the same $data1 results but for the life of me it doesn't work that way unless the actual page is displayed.

     

    Is my syntax wrong?

  14. Sorry People I'm not getting my emails when you respond to this thread.

     

    Basically this little snippet is only to serve a single simple purpose.

     

    IF a person is on a specific web page display an advertisement and or header image specific to that page.

     

    The idea was that I would enter the name of the page and then set the contents for that page in a variable or in this case $data and the contents of that would load.

     

    I could then do a simple php include for various areas of the site too.  Since the only objective here is to first get the http uri and then display the appropriate data accordingly. 

     

    I made a mistake by posting that code snippet with "current"  it was meant to be a generic thing.  It could actually be header.php or advertisement.php or randomfooter.php for example. 

     

    I just needed a simple way of controlling the contents on a per page basis.

     

    I'll do what you suggest.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.