php

When to use a Class vs. Function in PHP

The lightbulb has yet to go on for this... I'd really love an easy to understand explanation of the advantage to using a class in php over just using functions. Here's a simple example of the thought I'm having now and am wondering if a class is more efficient: Say I have a mini calendar widget that I've built in php. I'm thinking ...

Haxe PHP vs PHP - what language is better for creating Plugins for WordPress?

I want to create a WP plugin with use of WP DB tables and costume ones, Ajax requests Rss feeds reading and writing and media storing and Google maps. Such a crazy plugin it will be... So Haxe PHP or normal PHP - what language is better for creating Plugins for WordPress? BTW books blog articles and docs are appreciated as proofs for ...

How to show different homepage based on the user's Country?

I had two domains. rajasekar.com and rajasekar.in. What I need to do is that, when a user from India types the url in the address bar as www.rajasekar.com then it should open www.rajasekar.in When user from other country types the url in the address bar as www.rajasekar.com it should open www.rajasekar.com I think this is what im...

Are PHP MVC Controllers implemented by url rewrite?

The controller in a Java EE application may be represented by a servlet, which may be currently implemented using JavaServer Faces (JSF). But in PHP there is no such servlet,so I guess is it implemented by url rewrite? So that every request is directed to that controller? ...

Checkbox in first cell of each row in an html table displaying mysql query results

I have a simple HTML table display of data that results from an MySQL query. I would like to have a checkbox in the first cell of each row. I am asking for some suggestions as to where I might go looking for information on how to make this interactivity possible, as I'm sure this is not a "quick-answer" type of question. Example: http...

PHP Session Cookies stopped working on my server ONLY

I have a bizarre issue going on with my dev server. Just a few hours ago PHP session just totally quit working. Every single file (hundreds) started showing errors like below, about session cookies not being written. I cannot figure out what the problem is, what cause this to just start happening, before everything worked and I haven'...

Determine number of Dimensions in a PHP Array

Is there a way to determine how many dimensions there are in a PHP array? ...

PHP 6 not backward compatible

From what I read, PHP 6 will break a lot of php scripts. I understand the reasons why it may break but why don't they just keep the PHP 5 and simply call PHP 6 as a different language based on PHP syntax? Like for example, why not just call php 6 scripts with an extension, "p6"- why are they trying so hard to make it backward compatible ...

Convert php result array to json

Hai guys, I want to convert my result array to json format in php... Here is my code $row = mysql_fetch_array($result) Now i want to convert $row to json format... I want to pass the json data to autocomplete plugin of jquery.... ...

Can MYSQL support databases with sizes around 4 GB? Will I have any performance issues?

I am planning to have a database of size more than 12 million records all of them in a single table and no other joins etc, used for search, filtered based on field names of the table, approximately 4 GB size in MYSQL backend and php frontend. Question is can MYSQL support databases with sizes around 4 GB, Will I have any performance is...

Use php to trim URL to just domain name by removing protocol and path

Given "http://google.com/path-to-page" trip to "google.com" What php and regex would be appropriate? ...

Is this a correct JSON Data Structure?

guys, I've converted my php result array to json. Now I want to know is this in the correct json format. My code echo json_encode($row); I have to use it with jquery auto complete plugin... {"0":"1","id":"1","1":"Albania","country":"Albania"} {"0":"2","id":"2","1":"Algeria","country":"Algeria`"} {"0":"3","id":"3","1":"Angola","countr...

mystery mysql error

Hello all. I'm by no means experienced in mysql and keep getting an error in this lines of code: $sql= "INSERT INTO songs (unique_show_id, artist, date, year, city, state, venue, taper, transfered_by, source, mic_loc, lineage, uploaded_by, uploaded_on, show_notes, show_xml) VALUES('$showId', '$artist', '$showDate', '$year,...

Is OOP worth using on PHP?

There are many debates on whether Object Oriented Programming is good or not. But, using OOP in Php is slower. Would it be a good trade to use procedural programming and faster speed and OOP with slower speed (since classes have to be initiated every time a page loads and big websites will start to become slow). More importantly, would ...

PHP, IIS Image not displaying on browser

The following code is not displaying the image from IIS 6/PHP 5.2.9. It works OK from XAMPP (PHP 5.3) $img = @imagecreate(200, 200); $background_color = imagecolorallocate($img, 0, 0, 0); $text_color = imagecolorallocate($img, 233, 14, 91); imagestring($img, 12, 60, 90, 'image here', $text_color); header('Last-Modified: ' . date('D, d ...

How to make a onmouseover work in mysql catalog

Hi everyone! I'm having difficulty creating a button on my catalog page, the catalog page returns either 8 15 or 20 products from a mysql database so i use a loop to pull each product out of the database, and i need a addtocart button which uses javascript to create an onmouseover effect the code is as follows echo "<a href=\"catalog...

How To Make A jQuery Async Multi-Response From One PHP Script Run

I have a run.php that has a button on it called "Run". Clicking it does a jQuery $.get() AJAX call back to a response.php on the server, and sends the result to a Javascript callback function getResponse(sData) inside run.php's HTML for display back on the browser. I want to have things such that as response.php runs through a list of ta...

mysql_real_escape_string() for $_SESSION variables necessary?

Hi, Should I use the mysql_real_escape_string() function in my MySQL queries for $_SESSION variables? Theoretically, the $_SESSION variables can't be modified by the end-user unlike $_GET or $_POST variables right? Thanks :) ...

Assigning the result of a JavaScript confirm box to a PHP variable

//this is in php function msgbox($msg, $type) { if ($type == "alert") { // Simple alert window ?> <script language="JavaScript"> alert("<? echo $msg; ?>"); </script> <? } elseif ($type == "confirm") { // Enter Confirm Code Here and assign the $result variable for use // ...

assigning the result of a jsp confirm box to a php variable

//this is in php. function msgbox($msg, $type) { if ($type == "alert") { // Simple alert window ?> <script language="JavaScript"> alert("<? echo $msg; ?>"); </script> <? } elseif ($type == "confirm") { // Enter Confirm Code Here and assign the $result variable for use //...