php

To get the current URL to the next page by PHP's sessions

How can you use the part after the question mark in the url which comes as a output of the following variable? $_SERVER['HTTP_REFERER']; I run unsuccessfully if (0 !== $_GET['question_id'] && isset( $_GET['question_id'] ) ) { $result = pg_execute( $dbconn, "query_fetch", array( $_GET[...

PHP - Is rand(1,1000) = 1000 as probable as rand(1,1000) = rand(1,1000) ?

Is this how PHP implemented random number generating? Say I want to calculate a yes or a no. Everytime I have a certain probability percentage (say: 0,05% for this example). I do: $possibilities = 100 / $probabilityPercentage; //$possibilities = 2000 $yes = rand(1,$possibilities); $yesCheck = $possiblities; //OPTION 1 $yes...

PHP Transliteration

Are there any solutions that will convert all foreign characters to A-z equivalents? I have searched extensively on Google and could not find a solution or even a list of characters and equivalents. The reason is I want to display A-z only URLs, plus plenty of other trip ups when dealing with these characters. ...

Zend_Session problems

I have read..some articles on the internet, but i don't get it :|, can you guys give me an example, how to make something like this: $_SESSION['name'] = 'value'; and echo $_SESSION['name'].How can I create something like this, with ZF? Best Regards, ...

Converting input time 00 00 AM to DATETIME for MySQL

How can convert my time received from my $_GET variables as two digit values from a menu example: $hours = 04; $minutes = 45; $ampm = 'PM'; into the correct format to insert into a DATETIME field in MySql ...

What is required by strtotime to make a string/What are the defaults?

In a recent question, someone asked if they could make a time just using the hour, minute, and AM/PM parts of a standard time format. This led to my question, what is needed to create a time using strtotime? Do you need to have a date? If one is not provided, what date does it choose? Do you need to have a time? What is the default? Do...

Sessions and uploadify

I'm using uploadify, and i can't set sessions in my php files, my script looks like this: $("#uploadify").uploadify({ 'uploader' : '/extra/flash/uploadify.swf', 'script' : '/admin/uploads/artistsphotos', 'scriptData' : {'PHPSESSID' : '<?= session_id(); ?>'}, 'cancelImg' : '/imag...

Drupal 6 Views 2: PHP Snippets

I am using Views 2 to get information from my Drupal 6 site. After getting the data, I want to use a little PHP to do some calculations that are unavailable through Views + Views calc. What is the best way to go about doing this? I could alter the "Header" or "Footer" text, set the input format to "PHP Code", and try to access the $view...

PHP, login and logout time in temporary table?

Hi, I just read an article somewhere. They are using session_id store the login and logout time for every successful logged in user in a temporary table. Which means, the table would be deleted once the session destroyed. So why are they creating the tables?? Is there any use of the temporary tables? And why must use session_id?? What ...

How would you do this php code?

Is there a better way to write the below, other then using a switch or if/else statement? Like is this a situation where a PHP's varaiable variable ( $$var ) could come to use? If so how would you write this code? $type = 2; switch ($type) { case 1: $type = 'gif'; break; case 2: $type = 'jpg'; break; case 3: $type = ...

Posting to Blogger using PHP

I'm having a problem getting the Blogger API for PHP to work. What I need is to be able to post a new blogpost to my bloggeraccount. The code I'm using is taken from the Google API page here : http://code.google.com/intl/nl/apis/blogger/docs/1.0/developers%5Fguide%5Fphp.html Here is my code : <? require_once 'Zend/Loader.php'; Zend_Lo...

How do I get the siteURL calling my page when it is loaded in an iFrame?

Is it as easy as $ENV{'HTTP_REFERER'}? or is there something else that I need to do? Example: My Site: sample.php Calling Site w/iFrame: somesite.com I want sample.php when it loads to be able to use "somesite.com" for input as a variable. ...

How to walk a directory over a local network using PHP?

How can i list the contents of a windows share using PHP? $SearchFolder = "\\\\192.168.1.100\\pdfoutput\\"; if (is_dir($SearchFolder)) { if ($Directory = opendir($SearchFolder)) { while (($File = readdir($Directory)) !== false) { if(filetype($SearchFolder.$File) == "file") { $this->Attachments[] = n...

Designing a website for both javascript script support and not support

Okay i know that it's important for your website to work fine with javascript disabled. In my opinion one way to start thinking about how to design such websites is to detect javascript at the homepage and if it's not enabled redirect to another version of website that does not javascript code and works with pure html (like gmail) Anot...

PHP IF Statement Evaluation & Server Overhead

I'm curious what the impact on the server is when PHP if statements are evaluated, i.e. memory consumption and CPU usage and if this could become a major issue as traffic grows? For example, if I use a lot of PHP IF statements in the theme for each post summary on a WordPress blog, is this going to require a great deal more server resou...

Don't immediatly see the point behind this(php, school)

I'm a 2nd year ICT student. I never did PHP before this year and our instructor gave us the basics and at the end of the semester, gave us a project that would combine what we learned in his course and the databases course. We were to use the classic AMP setup on windows. Now, our instructor told us to make a profile-site, based on how ...

PHP: Arrays as Attributes

If I have an object with an array as an attribute, what is the easiest way to access it? $obj->odp = array("ftw", "pwn", array("cool" => 1337)); //access "ftw" $obj->odp->0 //access 1337 $obj->odp->2->cool This doesn't seem to work. Is there something I'm doing wrong, or do I have to first assign it to a variable? $arr = $obj->odp;...

Easy Non-GPL PHP Proxy

I'm trying to find a proxy PHP script that I can use to display a website, but also allow users to click on links continuing to use the proxy. Almost every one I have found that works is covered by the GPL license. I've looked into creating my own proxy, however I can't find a way to have the links on the page continue to use the proxy,...

Forum, get last post/topic

Basically, I'm writing a small forum script for an intranet. I've got 3 mysql (MySQLi) tables for the forum: forum_answer - holds replies forum_question - holds first posts forum_categories - holds names and description of categories. Ok, so on the forum index, I've got a table to fetch all the categories, however, I've also one colum...

PHP/MySQL: Retrieving the last Inserted Ids for multiple rows

Hi When inserting data into a table which has an auto-incremented PK, I need to obtain that key for use in another statement. As many questions show on SO this can be done in php using mysql_insert_id(). However, I have been grouping my inserts together so I insert more than one row at a time. I did this as I guessed there would pro...