php

How to grab URL parameters using PHP?

I'm trying to grab each URL parameter and display them from first to last, but I want to be able to display any of the parameters anywhere on the page. How can I do this? What do I have to add or modify on my script? Here is an example of a URL value. http://www.localhost.com/topics/index.php?cat=3&sub1=sub-1&sub2=sub-2&su...

PHP how to call included file functions

lets say i make a file Services.php <?php $myGlobalVar='ranSTR'; function serv1($num) { //some processing... return $num; } function serv2($num) { //some processing... return $num; } ?> and i include it in some other file lets say myFile.php by include "Services.php"; OR require "Services.php"; How can i call it...

How to extract parameters from a URL and storing each in a new variable using PHP

Possible Duplicate: How to grab URL parameters using PHP? I was wondering how can I store each url parameter each in there own new variable when I don't know how deep the url parameters are? Here is an example of a URL value. http://www.localhost.com/topics/index.php?cat=3&amp;sub1=sub-1&amp;sub2=sub-2&amp;sub3=sub-3&amp;sub...

PHP Variables Scope

file name myServices.php <?php $gender = 'MALE'; ?> in another file lets say file.php include "myServices.php" $name = 'SAM'; $age = '23'; ?> <!--after some more HTML code--> <?php $gender = 'FEMALE'; $name = 'ELENA'; //Question: //In the above statements are there new variables crea...

PHP/AJAX check if session variable changed

Greetings! I need to dynamically check if a session variable changes every few seconds. For example, the PHP session variable "x" may have a value of "1", and then after five seconds, has a value of "2". The PHP session variable "x" is changed by using a form. If the session variable changes, I need the page to reload. How can I relo...

combination regex and php still not work

hey all.i'm newbie at this problem.i have this data in table result: item range_code class red 123x0001-123x0500 A blue 123x0021-123x0100 //if null read zero green 123x0001-123x0300 b i want the result like: item qty ...

Trying to get new line on sms message sent from php script

I've been trying to get a new line generated in my sms message sent from a php script. I've used \r\n, and some hex codes. No matter what I do the message comes to my phone without line breaks. $body .= 'City:'.$venue.'\r\n'; <- doesn't work $body .= 'State:'.$state.''; <- doesn't work This is my header type...(complete header not inc...

having trouble with getting rows back from msqli::multi_query

I've got an sql query that contains a number of statements. It: sets a user variable calls a stored procedure calls another stored procedure selects some data I know that the query is correct, because I've tested it in MySQL Workbench, under the same user. The query is this: set @current_post = 535; /* 535 for testing, this will be ...

php: how to change string data become numeric data

dear all.. can you tell how to change this result in php and mysql script: Model Class Ball S Book A Spoon Plate B Box C this is my DB: CREATE TABLE IF NOT EXISTS `inspection_report` ( `id` int(11) NOT NULL AUTO_INCREMENT,...

Side Nav Menu Question.

How can I have all my nested lists collapse and expand when clicked. Here is my xHTML. <ul> <li><a href="some-link.php">First Nested List</a></li> <li><a href="some-link.php">First Nested List</a></li> <li><a href="some-link.php">First Nested List</a> <ul> <li><a href="some-link.php">Second Nested List</a></li> ...

Calculating download times with PHP Curl

I'm using PHP Curl to measure download times for a webpage. I know this isn't a good representation of actual download times for a browser; but I'm trying to get as close as possible using this method. My webpage has 3 files associated with it index.html my_pic.gif style.css I'm doing a Curl on each of those files then adding the do...

PHP Image Resize Classes

My website allows uploading of images. I limit images to 10 megapixel or less JPEG images, all images get stored in a directory. Now I want the images resized on the fly and I am looking for a PHP class/library that can do that for me. While I can write (and I have written) gd-library code for resizing images I want something that's stab...

IFRAME change source

Is it possible to change the source of an iframe when a link is clicked in the iFrame? For example, my iFrame loads http://www.google.com, but when I click a link on Google.com, the source of the iFrame cannot be changed to that new URL. Is there some way to access the iFrame location in Firefox and IE to redirect the iFrame? Sort of ...

Compare two timestamps in mysql, then return a custom field

I'm building a small scale forum script in PHP, and I am having difficulty demonstrating the read/unread status of a given thread. So, I have a particularly gargantuan query which returns the thread information, including the date it was first posted in, the date it was last posted in (if any) as well as the date it was last looked at b...

mysql_fetch_array Returning Two Of Everything

Hi all, I'm not exactly new to PHP but I haven't used MySQL that much, so I'll ask you guys about this one. I have a database with one row of data, which consists of a date and two integers. However, when I query the database with this: $query = "SELECT * FROM history"; $theQuery = mysql_query($query, $connect); $array = mysql_fetch_a...

Weird mysql error, not accepting variants of word 'select' when inserting / updating

I have a couple of textarea fields, which get saved into the database as text. If the textarea input has a select, selected or selecting in it, the query fails. I've never encountered this before. Am I doing something wrong? Here's the update query code as an example: $Query = "UPDATE project SET status = '".mysql_real_escape_string($_...

PHP - How to upload & Save Files with Desired name

i am using this code to upload files(images to a folder) <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input type='submit' name='upload_btn' value='upload'> </form> <?php $target_Path = "images/"; $target_Path = $target_Path.basename( $_FILES['userFile']['name'] ); move_uploaded_f...

Get the last insert id with doctrine 2?

How can I get the last insert id with doctrine 2 ORM? I didn't find this in the documentation of doctrine, is this even possible? ...

Is there an easy way to read filenames in a directory and add to an array?

Hi folks, I have a directory: Audio/ and in that will be mp3 files only. I'm wanting to automate the process of creating links to those files. Is there a way to read a directory and add filenames within that directory to an array? It'd be doubly cool if we could do an associative array, and have the key be the file name minus the ...

Finding frequent sequence of numbers in an array

Array (3, 5, 1, 3, 5, 48, 4, 7, 13, 55, 65, 4, 7, 13, 32) the frequent sequence of numbers will be (3, 5) f=2 + (4, 7, 13) f=2 any Algorithm or Pseudo code to find that ? Update(1): if (7, 13) also occurrence it will be included in the longest one by update its frequency so (4, 7, 13) f=3 and so on... Update(2): in case of (1,2,...