php

Extracting Browser Element from User Agent

I'm still working on the whole gathering user data from a visit thing, so I'm hung up on grabbing the actual name of the browser being used by the visitor. I have this code, but it seems that after execution, $browser is empty. $userAgent = mysql_real_escape_string($_SERVER["HTTP_USER_AGENT"]); $browser = get_browser($userAgent, tru...

Page including with mysql in php

I have a nice page including system here is the code for it if(isset($HTTP_GET_VARS['mod'])) { $page = $HTTP_GET_VARS['mod']; } else { $page = 'home'; } switch($page) { case 'home': require('home.php'); break; default: echo('Error: There is no file on this server with that name'...

php - parse friendly url

Hi, I have url like this /cp/foo-bar/another-testing how to parse it with the pattern /cp/{0}-{1}/{2} results will be 0:foo 1:bar 2:another-testing I need a global solution to parse all kind of url with a pattern like that. I mean using {0}, {1} flag. ...

Adding a new URL to the database using PHP & MySQL.

So far when I create a new sub category the url only grabs the new sub category but not the parent category for example if I create a new artists sub category of leonardo-da-vinci the new sub category url will be stored as, leonardo-da-vinci Output: http://www.example.com/leonardo-da-vinci when it should be stored as. arts-enterta...

Map all requests to subpaths of a script to the script itself

I have a script at: http:://vis.setihub.org/dataset/index.php/ I want the server to let the script handle requests of the form: http:://vis.setihub.org/dataset/index.php/mysubpath/ I can use the PATH_INFO available in PHP to see what subpath was requested. I just don't know how to make the server send the request to the script in the f...

get the filename of a given URL using PHP and remove the file extension.

I have a little snippet that grab's the filename, including the extension. $currURL = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); given a url... http://www.somewebsite.com/pretty/url/here/this-is-a-page.php it returns this-is-a-page.php. I would like to be able to return simply, this-is-a-page. I'm pret...

Any easy to use php mysql datagrid?

Hi Anyone know of a FREE and easy to use PHP MySQL Datagrid class? I have used rGrid and Eyesis but need something like phpdatagrid. No requirement of AJAX features though. Just need basic features inbuilt like search by columns, pagination with page numbers(with jump to page dropdown), how many rows to show per page, multiple delete etc...

Parse error: parse error, expecting PHP For Loop

. function is_valid_isbn($isbn) { $isbn_length = strlen($isbn); $isbn_sum = 0; echo "this is the length :"; echo $isbn_length; for($i=0; $i < $isbn_length; $i++) { $total += (substr($isbn, $i, 1) * (11-($i+1))); } return true; } When i run this function i am getting following error can some one help me where is the e...

PHP: get array element

Why does this code not work? echo explode("?", $_SERVER["REQUEST_URI"])[0]; It says syntax error, unexpected '['. Oddly, this works: $tmp = explode("?", $_SERVER["REQUEST_URI"]); echo $tmp[0]; But I really want to avoid to create such a $tmp variable here. How do I fix it? After the helpful answers, some remaining questions: I...

How to display categories and end-less sub categories using PHP & MySQL?

I was wondering what is the best way to display 100's of categories using PHP & MySQL? For example, it would not be wise to create a folder for each category or sub category. And how would I create my php page to display categories and end-less sub categories? And how would my url look like exactly for example with multiple sub catego...

SQL-injection - is this (oneliner) safe ?

PHP: $SQL = "SELECT goodies FROM stash WHERE secret='" . str_replace("'",'',$_POST['secret']) . "'"; Could an evil genius hacker inject SQL into my SELECT - How ? ...

passing .php array into a javascript code jquery/ajax

At the moment i have this piece of javascript code: //Display custom confirm box and delete multiple message $(document).ready( function() { $(".delete_button-multiple").click( function() { //Get message id as variable var id = $(this).attr("id"); var dataString = 'id='+ id ; var parent = $(this).parent(); //Display custom Confi...

how can i get specific data between div with file_get_content

suppose i echo out $url = "http://www.mydomain.com"; echo file_get_content($url); and http://www.mydomain.com has a div i.e <title>sitename</title> </head><body> Lorem Ipsum....... <div id="divname">and here is div content</div> Copyright bla bla bla no i want to only fetch content between div with id="divname" how can i do that ...

How can i find a parent id in Zend Framework?

I have a site with next structure. We have car's brands. If we click on link with brand, list with models of this model should be open. The url like this: http://example/brand/4. All good. But i don't know, how find a brand id. I need this, because i should know, where the models must be open (under what brand). I am using Router. Can ...

Getting output from a function that grabs numbers

I need to parse a number that has 3 s.f. and 2 d.p. (e.g. 2.34). The first two numbers (1st and 2nd s.f.) are then multiplied by 10. The second number stays as it is. Thus, for the example above, $a = 23 and $b = 4. I was able to get code similar to below to work when it was not a function but I would like to be able to incorporate the c...

how to modify this javascript time function to show hours less than ten as: 0x.

//Live Javascript Server Time function getthedate(){ var mydate=new Date() var hours=mydate.getHours() var minutes=mydate.getMinutes() var seconds=mydate.getSeconds() var dn="AM" if (hours>=12) dn="PM" if (hours>12){ hours=hours-12 } if (hours==0) hours=12 ...

How can I do the equivalent of submitting a form twice with PHP?

I have a problem with a form. I need it to perform two actions with only one submit click. I've read that the best solution is a server-side script, but my knowledge of PHP is pretty limited, so I'd really appreciate any help. The two actions I need to perform are: Run a script that uploads a file and sends an email (action="uploader....

CakePHP one to many Combo box

Hey I have two models User and City, where a user belongs to a city and a city has many users. On the city table I have city_id and city_name. I've used used cake bake and created the user model and when I add a new user the combos box under the city field is showing the id of the city instead of the name. I've tried several methods to...

Help for PHP newbie in results indexing using PHP

I am trying to create a multithreaded PHP script that POSTs the USN (University Seat Number) to the university results website and then indexes the result. Please give me the plot to do so. I started learning PHP a month ago. please do read the following: Valid USN regex is /^([12347]{1})([a-zA-Z]{2})([0-9]{2})([a-zA-Z]{2})([0-9]{3})$/...

PHP and cURL or otherwise. Can it retrieve JavaScript generated data?

I know this is very unlikely, but maybe there is another solution. What I want to do is retrieve JavaScript generated data from an external website. This isn't for an exploit, but rather a test. I noticed Google cannot index Ajax generated content.. but could they, and more importantly, how? I guess that is a better way of putting it....