php

Real pagination vs Next and Previous buttons

By real pagination i mean something like this when in page 3: <<Previous 1 | 2 | {3} | 4 | 5 |...| 15 | Next>> By Next and Previous buttons i mean something like this when in page 3: <<previous Next>> Performance wise im sure the Previous and Next Buttons are better since unlike the real pagination it doesn't require over-querying ...

Simple PHP query question: LIKE

When I replace $ordering = "apples, bananas, cranberries, grapes"; with $ordering = "apples, bananas, grapes"; I no longer want cranberries to be returned by my query, which I've written out like this: $query = "SELECT * from dbname where FruitName LIKE '$ordering'"; Of Course this doesn't work, because I used LIKE wrong. I've ...

What is wrong with my SQL syntax here?

New to SQL. I'm looking to create a IT asset database. Here is one of the tables created with php: mysql_query("CREATE TABLE software( id VARCHAR(30), PRIMARY KEY(id), software VARCHAR(30), key VARCHAR(30))") or die(mysql_error()); echo "Software Table Created.</br />"; This is the output from the browser when I run the script: ...

php $_REQUEST data is only half-decoded

I am retrieving an encoded url via querystring. I need to pass it again to the next page. When I retrieve it the first time, using $_REQUEST['url'], only the slashes are decoded, e.g: http://example.com/search~S10?/Xllamas&amp;searchscope=10&amp;SORT=D/Xllamas&amp;searchscope=10&amp;SORT=D&amp;SUBKEY=llamas/51%2C64%2C64%2CB/browse Th...

how to use a PHP Constant that gets pulled from a database

Can you read out the name of a PHP constant from a database and use it inside of a php variable, to display the value of the constant for use in a menu? For example here's what I'm trying to accomplish In SQL: select menu_name AS php_CONSTANT where menu_id=1 the value returned would be L_HOME which is the name of a CONSTANT in a php co...

Native language problem in mysql with tinyMCE

I have turkish character problem in mysql database when adding content with tinymce from admin panel. Charset is: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9"" /> How can I solve this? Thanks in advance ...

PHP: Bug narrowed down to one line, can't figure it out

So This part of my code: print_r($_SESSION['T']); $T = array_values($data2); print_r($_SESSION['T']); Outputs this: Array ( [0] => NZL ) Array ( [0] => ENG [1] => NZL ) That line is the first time $T is declared. As far as I can tell there should be NO reason for $_SESSION['T'] to gain an entry and its definitely causing me probl...

ob_start() -> ob_flush() doesn't work

I am using ob_start()/ob_flush() to, hopefully, give me some progress during a long import operation. Here is a simple outline of what I'm doing: <?php ob_start (); echo "Connecting to download Inventory file.<br>"; $conn = ftp_connect($ftp_site) or die("Could not connect"); echo "Logging into site download Inventory file.<br>"; ftp_...

Infinite throwing in constructor

What happens to a php script which goes like this? class FooException extends Exception { public function __construct() { throw new FooException; } } It's probably same as while (TRUE) { new Exception(); } It simply time outs when execution time is exceeded, or fails with some fatal error? ...

PHP code in drupal pages treating > as ?>

While working on an existing Drupal site I've noticed a strange glitch that causes any PHP operator with > in it to act like a ?> tag. This is happening in in Drupal pages that I create that have a 'Input Format' of 'PHP code'. For example this line of code foreach($array as $key => $value){ results in a very broken page that prints o...

Numerical /currency pre-formatted in a form displays and stores incorrect values

I have a form field that uses some Javascript to format user input 'price' field from say 1000 to 1,000.00 in real time before the form is submitted ..when I submit the form some PHP is reading the data and printing the results Javascript bit is num = num.substring(0,num.length-(4*i+3))+','+ PHP bit is 'price' => number_forma...

I want to scramble an array in PHP

I want PHP to randomly create a multi-dimensional array by picking a vast amount of items out of predefined lists for n times, but never with 2 times the same. Let me put that to human words in a real-life example: i want to write a list of vegetables and meat and i want php to make a menu for me, with every day something else then yest...

How often are design patterns used in the workplace using PHP

Hey everyone, I read a book awhile back called PHP Design Patterns and Practice, and ever since then I have been using design patterns whenever I think they are needed. However it just occurred to me that maybe most companies do not use design patterns very often for PHP, or at all. What I was wondering is, do most companies use design ...

How do I start using Linux for web development?

OK, so that's maybe not the best title, but I don't know exactly what I want to do, so, please, hear me out. I've used Windows pretty much all my life although I played with Linux on several occasions. At work everyone does web development with php on Windows using the same IDE and stuff. I would like to experience the powerful Linux c...

Multilingual webpage in TangoCMS

Is it possible to create and manage multilingual webpage by TangoCMS? I know that the AdminCP can be switched to another language than english (if it's translated and available). But is there a language switcher for front-end? Thanks. ...

PHP/json My field names are being truncated to 30 characters. Can I stop this?

Hi Everyone! Ok so I got this piece of vendor software that they said should be run on an apache php server and MySql database. I didn't have either of those so I put it on a PHP IIS server and I converted the code to work on SQL server. ex. mysql_select_db -> mssql_select_db (among other things) So I have the following code in a php...

PHP: Odd behaviour with date_sunset function

I'm having a look at the date_sunset function in PHP and have met an issue that I find a bit strange. I have this piece of code: $sunset = date_sunset(mktime(0, 0, 0, 5, 14, 2010), $format, // Format 55.596041, // Latitude 12.992495, // Longitude 90, // Zenith ...

Query only specified number of items from parent/child categories

I'm having trouble figuring out how to query every item in a certain category and only list the newest 10 items by date. Here is my table layout: download_categories category_id (int) primary key title (var_char) parent_id (int)</pre></code> downloads id (int) primary key title (var_char) category_id (int) date (date)</pre></code> ...

how to reverse this operation?

<?php echo (2884284 >> 16), '<br>'; // = 44 echo ((2884284 >> 16) & 0xFFFF), '<br>'; // 44 from the above i got 44 so how can i retrive from 44 to 2884284 ??? ...

Installed Programs/Computer Info for Web Application

I'm currently developing a support system for a university. The system is written in PHP and I would like to be able to get a current list of software and basic computer information on a computer. Basically when one of the faculty or staff creates a ticket from our web interface, I would like to have a Java Applet or similar that could b...