Jump to content

QuietWhistler

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

About QuietWhistler

  • Birthday 01/13/1991

Contact Methods

  • MSN
    quietwhistler@hotmail.com

Profile Information

  • Gender
    Male
  • Location
    The Netherlands

QuietWhistler's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello everyone, I'm trying to build a website that's relying on a cache system, I chose Memcache for this. However, when we've tried to install it on our Linux Server with Cpanel, and tested Memcache, I got the following error: "Cannot connect to localhost:11211". I have checked in the php.ini file and it says that Memcache is installed correctly, with the port 11211. Also, the line "memcache.so" is added in the php ini. However, I cannot seem to find the correct host. When I use the function $memcache->addServer(), the php info file shows 1 persistent connection. My question is how to configure the host correctly so that it will work. Thanks, Shady El Gewily
  2. You can do it like this: <?php $checkboxes = array( "designer1" => "Designer", "pm1" => "PM", "writer" => "Writer", "pm2" => "PM" ); if( is_array( $checkboxes ) ) { foreach( $checkboxes as $key => $value ) { print( "<input type=\"checkbox\" name=\"" . $key . "\" class=\"checkbox\" id=\"" . $key . "\" /> <label for=\"" . $key . "\">" . $value . "</label></div> )"; } } ?>
  3. $lastmtime = 0; $lastfname = ""; if ($dh = opendir("../upload/")) { while (false !== ($file = readdir($dh))) { if (filemtime($file) > $lastmtime) { $lastmtime = filemtime($file); $lastfname = $file; } } } echo "<img src='../upload/$lastfname' />";
  4. First of all, skunkbad made a mistake in his script. foreach($_POST['checkboxes'] as $key=>$val) { $data_name .= $key . ","; //mind the dot $data_value .= $val . ","; //mind the dot } $qry = mysql_query("INSERT INTO fake ($data_name) VALUES ('$data_value')") or die(mysql_error()); Now to get rid of the last comma, I always use this method: $i = 0; foreach($_POST['checkboxes'] as $key=>$val) { $data_name .= $key; $data_value .= $val; if( $i != sizeof( $_POST[ "checkboxes" ] ) - 1 ) { $data_name .= ","; $data_value .= ","; } $i++; } $qry = mysql_query("INSERT INTO fake ($data_name) VALUES ('$data_value')") or die(mysql_error());
  5. What I do to catch errors with foreach loops, is checking if the variable is actually an array. So like this: <?php $multi_winner[ $i ] = $row[ "invited_by" ]; if( is_array( $multi_winner ) { foreach( $multi_winner as $value ) { print( "stuff" ); } } ?>
  6. I'm not going to write the whole code for you now, but you could use regex to find the tags. With the results of that tag, split in to tag (ex. "JOB", "other tags" ), and value. What you would then do is create a switch statement for the tag value. Then you make a function for example getJobs( $amount ), whereas $amount would be the value extracted with regex. Then you would do like this: $replace = getJobs( $amount ); And replace the tag by $replace. Hope you can work with this information.
  7. Why don't you use the following statement then? <?php $sql = "SELECT * FROM payment WHERE Name LIKE '%$Name%' AND ( Date > '$new_date1' AND Date < '$new_date2' ) LIMIT $offset, $rowsperpage"; ?>
  8. You can use the phpZipLocator class. You can download it at http://www.sanisoft.com/downloads/ziploc/phpZipLocator.zip. You can then calculate the distance like this: <?php $oZip = new phpZipLocator(); $distance = $oZip->distance( $zip1, $zip2 ); ?>
  9. You can also set it it more easily by using the integrated SQL math. You would then update it as follows: <?php if( is_numeric( $newnum ) ) { mysql_query( "UPDATE table SET total = total + '$flthrs'" ); } ?>
  10. As long as the $_SESSION array keys are the same as the variable names you assign them to, you can use the following code: <?php $keys = array( "sendertitle", "senderforename" ); //etc. if( is_array( $keys ) ) { foreach( $keys as $key => $value ) { if( isset( $_SESSION[ $value ] ) ) { ${$value} = $_SESSION[ $value ]; //or $_POST } } } ?>
  11. Try using the following code: <?php include("conf.inc.php"); // Includes the db and form info. $result = mysql_query("SELECT fname,lname,haddress,hcity,hstate,hzip FROM users WHERE hzip = 76247"); while( $row = mysql_fetch_array( $result ) ) { echo $row[ "fname" ] . "<br />"; } ?>
  12. <?php $currentMonth = 2; //february integer value ?> <select name="month"> <?php $months = array( "January", "February", "March" ); //etc. for( $i = 0; $i < sizeof( $months ); $i++ ) { if( $currentMonth == ( $i + 1 ) { print( "<option selected>" . $months[ $i ] . "</option>" ); } else { print( "<option>" . $months[ $i ] . "</option>" ); } } ?> </select>
  13. You are not returning any values in your function, so the $scores and $average variables are terminated at the closing } of your function. To prevent this you could pass the parameters like this: function doCalc( &$scores, &$average ) This is called passing variables by reference. It means that everything you do to those variables in your function, will stay that way, even when the function is closed.
  14. You can't use comparison operators in an URL. Just assign the variables like: http://www.website.com/index.php?sdate=20080601&&edate=20080701 and then use that query.
  15. $sql = "SELECT * FROM `table` WHERE `sdate` > '" . $_GET[ "begin" ] . "' && `edate` < '" . $_GET[ "edate" ] . "'"; mysql_query( $sql ); That should do it.
×
×
  • 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.