Jump to content

nbarone

Members
  • Posts

    90
  • Joined

  • Last visited

    Never

Posts posted by nbarone

  1. I am trying to merge two images... the background image will have an overlay that is basically a border around the image...

     

    Here is my code, but it's only outputting the background image and not the overlay.

    <?php	
    
    // define base image, this is the custom image
    $background = "../images/frontpage/fpgtest.png";
    $overlay = "../images/assets/fpgraphic_overlay.png";
    
    // create image
    $background = imagecreatefrompng($background);
    $overlay = imagecreatefrompng($overlay);
    
    // define colors
    $white = imagecolorallocate($background, 255, 255, 255); // transparent
    
    // apply trans color
    //imagealphablending($background, true);
    //imagesavealpha($background, true);
    //imagecolortransparent($background, $white); 
    
    // define header
    header ("Content-type: image/png"); 
    
    // Merge Image
     imagecopymerge($background,$overlay,0,0,0,0,0,0,100);
    
    
    // display image
    imagepng($background);
    imagedestroy($background);
    
    ?>

     

  2. I am trying to load in a PNG image, and place a number on top of it. This code is not outputting anything (not even an error):

    <?php
    // define base image
    $base = ($_GET['hover']=='true')?"/images/assets/sel_hover.png":"/images/assets/sel.png";
    
    // create image
    $image = imagecreatefrompng($base);
    
    // define colors
    $black = imagecolorallocate($image, 0, 0, 0);		// text
    
    // define font file
    $font = "helvetica.ttf"; 
    
    // define incremental number
    $num = $_GET['inc'];
    
    // define header
    header ("Content-type: image/png"); 
    
    // write text to image
    imagettftext($image,10,0,3,3,$black,$font,$num);
    
    // display image
    imagepng($image);
    imagedestroy($image);
    
    ?>

     

  3. Hi, I have a multidimensional array and I would like to sort it by the length of the first key.

     

    The first key is a file path, the second key is a file id, and then several parameters under that.

     

    $filelist['\\fileserver\share\path\to\file']['1234']['name'] = "video.avi";

     

    If possible, I would like to sort the first key in a tree-like format

    example:

    $filelist['\\fileserver\share\'] = $filelist[0]

    $filelist['\\fileserver\share\folder1'] = $filelist[1]

    $filelist['\\fileserver\share\folder1\anotherfolder\'] = $filelist[2]

    $filelist['\\fileserver\share\folder1\anotherfolder2\'] = $filelist[3]

    $filelist['\\fileserver\share\folder2\'] = $filelist[4]

     

    Also, I would like to story the filenames alphabetically

    $filelist['\\fileserver\share\path\to\file']['1234']['name'] = "video.avi";

     

    I don't know how I would do this all with such a complex array.

     

     

  4. I'm hoping someone here will have a better eye at catching this error than I have.

     

    Thanks in advance.

     

    Actual code:

    $sql = "INSERT INTO mfl_files (file_name, file_share, file_path, file_created, file_modified, file_lastVerified, file_active)
    VALUES ('$file', '$shr_id', '$dir', '$dateCreated', '$dateModified', '$newDateVer', '1')";

     

    $sql output:

    INSERT INTO mfl_files (file_name, file_share, file_path, file_created, file_modified, file_lastVerified, file_active) 
    VALUES ('09-6-2009-dvd.mov', '1', '\\fileserver01\SHARE01\VIDEO\DVD Files\2009\', '2009-11-24 09:33:11', '2010-02-03 16:37:34', '2010-02-25 10:37:28', '1')

     

    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 '2009-11-24 09:33:11', '2010-02-03 16:37:34', '2010-02-25 10:37:28', '1')' at line 2

  5. Well I have an include file that pulls a num_rows variable from the database.

    I have this page included in a few different pages throughout the site - however, on just one page, it runs very slow.

     

    here's the script:

    <?php
    
    $foxridge[8] = 3;
    $foxridge[6] = 6;
    
    $alpine[8] = 10;
    $alpine[6] = 10;
    
    $valley[8] = 5;
    $valley[6] = 1;
    
    $inn[2] = 10;
    $inn[4] = 89;
    
    $wildflower[2] = 23;
    $wildflower[4] = 32;
    $wildflower[6] = 20;
    
    $snowpine[2] = 4;
    $snowpine[4] = 18;
    $snowpine[6] = 30;
    $snowpine[8] = 15;
    
    foreach($foxridge as $k=>$v){
    $sql = "SELECT b_id FROM breakaway WHERE b_location='foxridge' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$foxridge[$k] = false;
    	//echo "<br>Foxridge: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
    	echo date("H:i:s");
    	echo "<br>";
    }
    
    foreach($alpine as $k=>$v){
    $sql = "SELECT b_id FROM breakaway WHERE b_location='alpinemeadow' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$alpine[$k] = false;
    	//echo "<br>Alpine: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
    	echo date("H:i:s");
    	echo "<br>";
    }
    foreach($valley as $k=>$v){
    $sql = "SELECT b_id FROM breakaway WHERE b_location='valleyvillage' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$valley[$k] = false;
    	//echo "<br>Valley: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
    	echo date("H:i:s");
    	echo "<br>";
    }
    foreach($inn as $k=>$v){
    $sql = "SELECT b_id FROM breakaway WHERE b_location='inn' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$inn[$k] = false;
    	//echo "<br>The Inn: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
    	echo date("H:i:s");
    	echo "<br>";
    }
    foreach($wildflower as $k=>$v){
    $sql = "SELECT b_id FROM breakaway WHERE b_location='wildflower' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$wildflower[$k] = false;
    	//echo "<br>Wildflower: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
    	echo date("H:i:s");
    	echo "<br>";
    }
    foreach($snowpine as $k=>$v){
    $sql = "SELECT b_id FROM breakaway WHERE b_location='snowpine' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$snowpine[$k] = false;
    	//echo "<br>Snowpine: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
    	echo date("H:i:s");
    	echo "<br>";
    }
    
    $twos = true;
    $fours = true;
    $sixs = true;
    $eights = true;
    
    if(($snowpine[2]==false)&&($wildflower[2]==false)&&($inn[2]==false)){
    $twos = false;
    }
    if(($snowpine[4]==false)&&($wildflower[4]==false)&&($inn[4]==false)){
    $fours = false;
    }
    if(($snowpine[6]==false)&&($wildflower[6]==false)&&($valley[6]==false)&&($foxridge[6]==false)&&($alpine[6]==false)){
    $sixs = false;
    }
    if(($snowpine[8]==false)&&($valley[8]==false)&&($foxridge[8]==false)&&($alpine[8]==false)){
    $eights = false;
    }
    
    ?>

     

    now it will output the timestamp of each query, so I can debug.

    on one page it looked like this:

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

    09:53:32

     

    on the page in question, it took about 1 second per query:

    09:56:14

    09:56:14

    09:56:15

    09:56:16

    09:56:17

    09:56:19

    09:56:20

    09:56:21

    09:56:22

    09:56:23

    09:56:24

    09:56:25

    09:56:26

    09:56:27

    09:56:28

     

    as you can see this dramitically increases page load time (this is for older women, they will think the world ended if it doesn't load in 5 seconds and keep clicking  :facewall::shrug:)

     

    The first page, which loads the include very fast start out like this (checkRooms.php is the include in question)

     

    <?php
    session_start();
    session_destroy();
    session_start();
    include('db.php');
    require('checkRooms.php');
    ?>

     

    the second page is VERY simalir:

    <?php
    session_start();
    include('checkRooms.php');
    ?>

     

     

    why would this code load sooooooooo slow on only this page? this makes no sense to me. the worst part is everything loaded nice and fast until this morning  :shrug:

  6. It's best to use a switch, because of security issues.

    <?php
    switch($_REQUEST['page']){
        case "home":
            include('homepage.html');
        break;
        case "products":
            include('products.html');
        break;
        default:
            include('homepage.html');
        break;
    }
    ?>

  7. I am setting up a registration form for a trip.

    The variable name is the location name

    the key is the number of people who can fit in a room at that location

    the value is the number of rooms available that will fit that many people.

     

    I want to scan the DB for the number of people registered for that location, with there number of roommates, and see if any rooms are still available.

     

    Here is my script, but I feel like it can be done in a better way. Any input is appreciated.

     

    <?php
    // NUMBERS
    
    $foxridge[8] = 3;
    $foxridge[6] = 6;
    
    $alpine[8] = 10;
    $alpine[6] = 10;
    
    $valley[8] = 5;
    $valley[6] = 1;
    
    $wildflower[2] = 23;
    $wildflower[4] = 32;
    $wildflower[6] = 20;
    
    $snowpine[2] = 4;
    $snowpine[4] = 18;
    $snowpine[6] = 30;
    $snowpine[8] = 15;
    
    foreach($foxridge as $k=>$v){
    $sql = "SELECT * FROM breakaway WHERE b_location='foxridge' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$foxridge[$k] = false;
    }
    
    foreach($alpine as $k=>$v){
    $sql = "SELECT * FROM breakaway WHERE b_location='alpinemeadow' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$alpine[$k] = false;
    }
    foreach($valley as $k=>$v){
    $sql = "SELECT * FROM breakaway WHERE b_location='valleyvillage' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$valley[$k] = false;
    }
    foreach($wildflower as $k=>$v){
    $sql = "SELECT * FROM breakaway WHERE b_location='wildflower' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$wildflower[$k] = false;
    }
    foreach($snowpine as $k=>$v){
    $sql = "SELECT * FROM breakaway WHERE b_location='snowpine' AND b_numRoommates='".$k."'";
    if(mysql_num_rows(mysql_query($sql)) >= $v)
    	$snowpine[$k] = false;
    }
    ?>

  8. here's what I got:

    <?php
    function getNumRows($qry){
    		if($qry <> NULL){
    			$qry = "SELECT * FROM epostcard WHERE ".$qry;
    		} else {
    			$qry = "SELECT * FROM epostcard";
    		}
       		$result = mysql_query($qry);
    		$numRows = mysql_num_rows($result);
    		unset($qry,$result);
    		return $numRows;
    	}
    
    $totalPostcards = getNumRows("p_pcSentDate <= '". $dateStart . "' AND p_pcSentDate >= '" . $dateEnd . "'");

     

    this returns 0 rows. (incorrect)

     

    $totalPostcards = getNumRows("p_pcSentDate BETWEEN '". $dateStart . "' AND '" . $dateEnd . "'");

     

    this returns the correct rows, however I need to get the rows that are on dateStart and dateEnd - this does the rows BETWEEN (obv),

  9. <ul>
    <?php
    $sql = "SELECT * FROM table";
    $result = mysql_query($sql);
    while($row = mysql_query($result)){
        extract($row);
        echo "<li>".$menu_link."</li>";
    }
    ?>
    </ul>

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