Jump to content

phpretard

Members
  • Posts

    821
  • Joined

  • Last visited

    Never

Posts posted by phpretard

  1. I am trying to compare values and if the month is not of 2 digits then the comparison goes wrong.

     

    Here is some hacked crap that doesn't work.

    
    if (strlen($_POST['m'] <= 1)){$month = "0".$_POST['m'];}else{$month = $_POST['m'];}
    if (strlen($_POST['d'] <= 1)){$day = "0".$_POST['d'];}else{$day = $_POST['d'];}
    
    <form>
    
    function GetDays(){
        $Listd = '<select name="d">';
    if (isset($_POST['d'])){$Listd .='<option value="'.$_POST['d'].'">'.$_POST['d'].'</option>';}
        for ($x = 1; $x <= date('d'); $x++)
    $Listd .= '<option value="'.$x.'">'.$x.'</option>';
        $Listd .= '</select>';
        return $Listd;
    }
    
    function GetMonths(){
        $Listm = '<select name="m">';
    if (isset($_POST['m'])){$Listm .='<option value="'.$_POST['m'].'">'.$_POST['m'].'</option>';}
        for ($x = 1; $x <= date('m'); $x++)
    $Listm .= '<option value="'.$x.'">'.$x.'</option>';
        $Listm .= '</select>';
        return $Listm;
    }
    
    

     

    Here is what I am comparing:

    Now:          201012141292327875

    Submitted: 201110101292353200 // 2 digit month/day

     

    Now:          201012141292327984

    Submitted: 2011991292353200 // not 2 digits month/day

     

    2 hours is enough for me...can someone shed some light on this for me please?

  2. I have a form that submits G

     

    How can I convert this to string of time when I need to insert it into the database and then turn it back around when it needs to be read?

     

              
    <option>11:00 AM</option>
    <option>11:30 AM</option>
    <option>12:00 PM</option>
    <option>12:30 PM</option>
    <option>1:00 PM</option>
    <option>1:30 PM</option>
    

     

    Thank you.

  3. This shows the value from 2010 to 1992:

    <?php
      $dateAllowedSelect = date('Y') - 18;
      $myCalendar = new tc_calendar("DOB", true);
      $myCalendar->setPicture("images/iconCalendar.gif");
      if (isset($_POST['DOB'])){
    	 $expDOB = explode("-", $_POST['DOB']);
    	 $myCalendar->setDate($expDOB[2], $expDOB[1], $expDOB[0]);
    	  
      }else{
    		$myCalendar->setDate(date('d'), date('m'), date('Y'));
      }
      
      $myCalendar->setPath("./");
      $myCalendar->setYearSelect($dateAllowedSelect, date('Y'));
      $myCalendar->dateAllow('$dateAllowedSelect-01-01', date('Y-m-d'));
      $myCalendar->writeScript();
    ?>
    

     

    This only shows 2010:

     

    <?php
      $dateAllowedSelect = date('Y') + 3;
      $myCalendar = new tc_calendar("DOP", true);
      $myCalendar->setPicture("images/iconCalendar.gif");
      if (isset($_POST['DOP'])){
    	 $expDOP = explode("-", $_POST['DOP']);
    	 $myCalendar->setDate($expDOP[2], $expDOP[1], $expDOP[0]);
    	  
      }else{
    		$myCalendar->setDate(date('d'), date('m'), $dateAllowedSelect);
      }
      $myCalendar->setPath("./");
      $myCalendar->setYearSelect($dateAllowedSelect, date('Y'));
      $myCalendar->dateAllow('$dateAllowedSelect-01-01', date('Y-m-d'));
      $myCalendar->writeScript();
    ?>
    

     

    I can't figure the problem.

  4. 
    <?php
    //new function
    
    $to = "post@example.com";
    $nameto = "Who To";
    $from = "post@example.com";
    $namefrom = "Who From";
    $subject = "Hello World Again!";
    $message = "World, Hello!"
    authSendEmail($from, $namefrom, $to, $nameto, $subject, $message);
    ?>
    
    
    <?php
    /* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */
    
    //Authenticate Send - 21st March 2005
    //This will send an email using auth smtp and output a log array
    //logArray - connection,
    
    function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message)
    {
    //SMTP + SERVER DETAILS
    /* * * * CONFIGURATION START * * * */
    $smtpServer = "mail.server.com";
    $port = "25";
    $timeout = "30";
    $username = "smtpusername";
    $password = "smtppassword";
    $localhost = "localhost";
    $newLine = "\r\n";
    /* * * * CONFIGURATION END * * * * */
    
    //Connect to the host on the specified port
    $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);
    $smtpResponse = fgets($smtpConnect, 515);
    if(empty($smtpConnect))
    {
    $output = "Failed to connect: $smtpResponse";
    return $output;
    }
    else
    {
    $logArray['connection'] = "Connected: $smtpResponse";
    }
    
    //Request Auth Login
    fputs($smtpConnect,"AUTH LOGIN" . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['authrequest'] = "$smtpResponse";
    
    //Send username
    fputs($smtpConnect, base64_encode($username) . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['authusername'] = "$smtpResponse";
    
    //Send password
    fputs($smtpConnect, base64_encode($password) . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['authpassword'] = "$smtpResponse";
    
    //Say Hello to SMTP
    fputs($smtpConnect, "HELO $localhost" . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['heloresponse'] = "$smtpResponse";
    
    //Email From
    fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['mailfromresponse'] = "$smtpResponse";
    
    //Email To
    fputs($smtpConnect, "RCPT TO: $to" . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['mailtoresponse'] = "$smtpResponse";
    
    //The Email
    fputs($smtpConnect, "DATA" . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['data1response'] = "$smtpResponse";
    
    //Construct Headers
    $headers = "MIME-Version: 1.0" . $newLine;
    $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
    $headers .= "To: $nameto <$to>" . $newLine;
    $headers .= "From: $namefrom <$from>" . $newLine;
    
    fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n");
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['data2response'] = "$smtpResponse";
    
    // Say Bye to SMTP
    fputs($smtpConnect,"QUIT" . $newLine);
    $smtpResponse = fgets($smtpConnect, 515);
    $logArray['quitresponse'] = "$smtpResponse";
    }
    ?>
    
    

     

    REF: http://www.codewalkers.com/c/a/Email-Code/Smtp-Auth-Email-Script/

  5. Maybe this

     

       //-------------------------- DEDUCT POINTS --------------------------------
       $point_total = $row['scm_points'];
       $point_minus = $point_total * .1;
       $points = round($point_minus);
       echo "Begining: $point_total <br />";
       echo "Minus 10% Rounded: $points";
       // need to pull existing points (field: scm_points) from the above SELECT statement and deduct 10% (rounded)

  6. I am using pieces of an array like this:

     

    $data['0'];

    $data['2'];

    $data['3']; and so on...I think up to around $data['70'];

     

    I need to take the values of $data['29'] through $data['64'] and combine them. (stumped)

     

    On top of that I have to comma separate those now combined values (stumped).

     

    Actuall Code:

    
    $handle = fopen("test.csv", "r");
    
    while (($data = fgetcsv($handle, 5000, ",")) !== FALSE){
    
                $needed = $data['29'] .", ". $data['30'] .", ".$data['31']; // ALL THE WAY TO $data['65']
            
             }
    
    

     

    I know how to do it the long way, could someone help me shorten my work?

     

    Thank you for your help.

     

  7. I have a list of pictures and I want to control the order.

     

    Here is the picture format:
    $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_1.jpg
    $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_2.jpg
    $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_3.jpg
    $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_4.jpg
    $pic = http://www.picture.biz/incoming/w_2GTEK13T961240561_5.jpg
    
    Notice the order 1.jpg, 2.jpg, etc..
    
    Here is where I'm stuck...
    
    // begin stuck 
    $orderPic = explode("_", $pic);
    
    foreach($orderPic as $rank){
         echo "$rank"; // I need $rank to equal 1 then 2 then 3 ...
    }
    

     

    It would be nice actually if I could start the insert with number 2 because number one is always a screwy picture.

     

    I hope this makes sense /  Thank for the help!

     

     

  8. I need to some how pull comma separated images $data[23] from this $data array and then put them into there own array so I can insert them into separate rows in a database.

     

     

        
    This is the provided array:
    
    $data[0] => VIN
    $data[1] => StockNumber
        
    ...(all the other number here)
        
    $data[23] => Image_URLs (comma seperated)
    $data[24] => Equipment
    
    
    // I need something like this (obviously doesn't work?!@#)
    
    $delimiter = ",";
    $img = explode($delimiter, $data[23]);
    
    foreach($img as $pic){
    $sqlPic = "insert into class_prodimages (pid image rank) values('".$LastId['id']."', '$pic', '".rand(1,20)."')"; 
    
    }
    

     

     

    Any help here?

     

  9. My bad ... here is the code

     

    $sql = "select * from class_car_types";
    $getem = mysql_query($sql);
    while ($cartype = mysql_fetch_assoc($getem)){
    
    while (($data = fgetcsv($handle, 5000, ",")) !== FALSE){
    
    $title = $data[3]." ".$data[4];
    
    $sqlcat = "select * from class_car_types where make = '".$data[3]."' and model = '".$data[4]."'";
    $querycat = mysql_query($sqlcat);
    
    	while($getID = mysql_fetch_assoc($querycat)){
    		$cat = $getID['cat'];
    
    		$shortDescription = str_replace(",","&#44;", $data[20]);
    		$description = str_replace(",","&#44;", $data[19]);
    
    		$sqlinsert = "insert into class_listings
    		(
    		 owner, title, section, shortDescription, description, 
    		 featured, price, display, hitcount, dateadded, expiration, 
    		 notified, searchcount, repliedcount, pBold, pHighlighted, notes, orderID
    		 )
      values(
    		 '6', '$title', '$cat', '".stripslashes("$shortDescription")."', '".stripslashes("$description")."', 
    		 'Y', '".$data[17]."', 'Y', '0', '".date('Y-m-d H:i:s')."', 
    		 '$exp', 'N', '0', '0', 'Y', 'Y', 'NULL', '".rand(10,1000)."'
    		 )
    		"; 
    
    		//echo "$sqlinsert<br /><br /><hr />";
    		$sqlinsert1 = mysql_unbuffered_query($sqlinsert) or die(mysql_error());
    	}
    
    }
    
    
    }
    free($getem);
    free($querycat);
    
    

     

  10. I don't get it.  The query before this one inserted and it basically has the same info.

     

    Here is the error:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Choice Award Winner * Named Best Muscle Car by Car and Driver's 10 Best Cars for' at line 8

     

    Here is the query...

     

    insert into class_listings ( owner, title, section, shortDescription, description, featured, price, display, hitcount, dateadded, expiration, notified, searchcount, repliedcount, pBold, pHighlighted, notes, orderID ) values( '6', 'FORD MUSTANG', '16', 'A Consumer Guide 2006 Best Buy * A contender for Motor Trend 2005 Car of the Year * MotorWeek 2006 Drivers' Choice Award Winner * Named Best Muscle Car by Car and Driver's 10 Best Cars for 2005 * AutoWeek named Mustang a finalist in the 2005 North American Car of the Year Awards *Named on the Automobile Magazine 50 Great New Cars List *', 'Clean CarFax vehicle history report-titled twice with no accident indicators. Fun to drive 5-speed manual transmission, luxurious leather, ABS, traction control, power driver's seat, interior upgrade package, and wheel locking kit. Ford Certified Pre-owned includes a 6 year/100,000 mile limited warranty with roadside assistance.', 'Y', '20995', 'Y', '0', '2010-10-29 17:20:11', '2010-11-29 17:20:11', 'N', '0', '0', 'Y', 'Y', 'NULL', '786' )
    

  11. I am trying to display "open" / "closed" depending on the time of day.  I tried to write my own script but it doesn't seem to be working.  Does anyone know of some boxed script I can use?

     

    Here is what I have...

     

    
    function open(){
    
    $AMPM = date('A', time());	
    if ($AMPM == "PM"){
    
    connect();
    
    $day = date('l');
    
    
    $sqlcurrent = "select * from hours where day = '$day' and closed ='1'";
    $currently = mysql_query($sqlcurrent) or die(mysql_error());
    $checkDay = mysql_num_rows($currently);
    
    if ($checkDay == "1"){
    		while($getID = mysql_fetch_assoc($currently)){
    
    			$convertopen = strtotime($getID['open']);
    			$convertclose = strtotime($getID['close']);
    
    			$displayTimeH = date('H', time());
    			$displayTimeM = date('i', time());
    			$displayTimeAMPM = date('A', time());
    
    			$opentime = explode(":", $getID['open']);
    			$openhour=$opentime[0];
    			$openminute=$opentime[1];
    
    			$closetime = explode(":", $getID['close']); 
    			$closehour=$closetime[0];
    			$closeminute=$closetime[1];			
    
    			//echo "$closehour$closeminute<br />";
    			//echo "$displayTimeH$displayTimeM<br />";
    
    
    			if (($openhour <= $displayTimeH && $openminute <= $displayTimeM) && ($closehour >= $displayTimeH && $closeminute >= $displayTimeM)){
    					echo "We're Open ... Come On In!";
    				}else{
    					echo "Hours of Service";
    				}
    
    
    		}
    }else{
    echo "Hours of Service";
    free($currently);	
    
    }
    }else{
    echo "Hours of Service";	
    }
    } // close function
    
    

     

    I know it's brutal but it's all I could come up with...

  12. I need to compare current time to data based time.

     

    Time in the database is in this format > 00:00:00

    Easy enough. 

     

    >>>>What I need is to convert "00:00:00" format into "time();" format<<<<

     

    The opposite is below...it's all I could come up with so far.

     

    <?
    $gettime = time();
    $displayTime = date('H:i:s', time());
    echo $displayTime;
    ?>
    

     

    Thank you.

  13. I did hold out some info (my bad)...

     

    Here is the code in full.

     

     

     

    
    if (isset($_POST['updateorder'])){
    connect();
    	$changeorder = mysql_unbuffered_query("update links set `order` = '".$_POST['linkorder']."' where id = '".$_POST['id']."'") or die(mysql_error());
    
    }
    
    

     

    
    <form action="" method="post" autocomplete="off">
    <table class="links" width="100%" border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td align="center" class="label">ORDER</td>
        <td class="label">LINK NAME</td>
      </tr>
    
    <?
    connect();
    $display = mysql_query("select * from links order by `order`") or die(mysql_error());
    while($row = mysql_fetch_assoc($display)){
    
    echo"
      <tr onMouseover=\"this.style.backgroundColor='pink';\" onMouseout=\"this.style.backgroundColor='';\">
      	<td align=\"center\">
    	<input style=\"text-align:center\" type=\"text\" name=\"linkorder\" value=\"".$row['order']."\" size=\"2\" />
    	<input type=\"hidden\" name=\"id\" value=\"".$row['id']."\"/>
    </td>
    <td>".$row['link']."</td>
      </tr>
    ";
    
    }
    free($display);
    ?>
    
    </table>
    <input type="submit" name="updateorder" value="Save Order" />
    </form>
    
    

     

×
×
  • 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.