php

PHP optimize code

Several questions on "what is the shortest code for this?": 1) Without {} if($match->name == "Marry") { $match = true; } 2) Without {} if($match->name == "Marry") { $match = true; } else { $match = false; } 3) How to ask if $match = true? 4) How to ask if array() has any value? 5) How to ask if $variable has ...

Get id of element and post in sql query?

Hey, I am trying to get the id of an element and then post that id in a sql query like this: jQuery gets id of checkbox: $(document).ready(function() { $(":checkbox").change(function(){ var id = $(this).attr('id'); $.post("index.php", { id: this.id, checked: this.checked }, function(data){ ...

MYSQL ordering data from 1 table using the 2nd table

Is there a MYSQL query I can use to order items from a second table. My example I'm listing My Stores... each store has a number of products in a diffrent table. so my store listing displays the number of products in that store.. is there an easy MYSQL query so i can order my stores by number of products my store doesnt hold a value o...

How XSS attack really works?

Hey, So, preventing website from XSS attack is very simple, you just need to use htmlspecialchars function and you are good. But if developer forgot to use it, what can attacker/hacker do? He can get your session_id, right? And here is a question. What can he do with that? Thank you very much. ...

How to disable archives & meta wdigets on wordpress ?

Hi ! I need to disable archieves and meta widgets on our website - cbms.ru ( make them not to show up ) how do i do this ? thankx ! ...

Add a Ubuntu User from Web Interface

Hi, I have been tasked with the job of creating a web based system to add system users to our Ubuntu linux server. I have been reading up online, and there seems to be a fair few different ways to go about doing it, none of which really have examples. I understand the best way for me to do it would be to temporary give sudo to the apac...

PHP merge variables

How to merge these (make this code shorter)? $match_1 = false; $match_2 = false; $match_3 = false; $match_4 = false; $match_5 = false; And how to shorter this code: if($match_1 == false) { ... } // if(!$match) must work? ...

PHP:HTML markup breking when taking first 200 chars

in my PHP web application,I have a dataentry form where users will enter data using a rich text editor (FCKEditor i m using) and will be saving the Markup from the editor to the DB table.In another page i have to display the first 200 chars of the content (with View more link to view the entire thing). So when i m taking first 200 chars,...

Programmers or Framework

Without going into the specifics if our dev team is use to programming in pure PHP/MySQL but after 6 months of working with a framework they are still taking twice as long to do things in the framework is it them or the framework? I am inclined to think the members of the dev team are lacking in skills as their work in pure PHP/MySQL ...

ORDER BY in PHP/MYSQL not working

The sql query is $query = mysql_query( "SELECT * FROM games ORDER BY gamename" ); But it doesn't order them by the gamename. This is a sample of the database id (int) | gamename (text) | gameurl (varchar) | width (int) | height (int) 1--------- Copter ---------- copter ----------- 100 ---------- 200-------- 2--------- Adrenaline -...

php try... else

is there something similar in php to the try... else in python? I need to know if the try block executed correctly as when the block executed correctly, a message will be printed. ...

When programming in PHP is it better to use stored procedures or hard coded SQL?

Currently, I only use stored procedures, is this considered good practice or bad? I find it helpful to separate my SQL code from my PHP code, and I also remember hearing in a PHP course I took a few semesters back that stored procedures are more secure. ...

XML - CSV data output: server-client interaction and optimization

Hi gurus, I am planning an application that involves pulling XML data from the server side and manipulating it on the client side before allowing the user to save it as CSV. On the server side, I will use Apache and PHP as the primary service interface, and the data source could be coming from MySQL server and/or Exist database server....

How to tell when a PHP Fatal Error is really a veiled Syntax Error, and when do they happen?

Considering the following PHP class: class someObject { public function broken(){ return isset($this->something()) ? 'worked' : 'didnt'; } public function something(){ return true; } public function notBroken(){ print('worked'); } } Let's say I now do: $obj= new someObject(); $obj->br...

rich text editor for textarea

can some of you guys suggest me some free rich text editor for textarea? I like the one that stackoverflow uses. ...

php headers for a .apk file is not working when downloading on the phone

I am trying to download an Android APK file that is output by a php page. I have the following and it works on firefox but not on the phone. Firefox downloads with an apk extension but has a little firefox icon next to it. The phone downloads the file with a .html extension, why is this? UPDATE: Full source function display($tpl = ...

jQuery Load JSON

Hello, I've got a small dilemma, that should hopefully be easy to resolve. I am loading some data using jQuery/JSON/PHP-- essentially, the data being loaded are several <li> elements. The following code works correctly: function load_list() { $.getJSON('json/load.php', function(data) { $.each(data, function(k, v){ ...

php and mysql, best practices

I started working with php and mysql today. Basically, what I have, is an empty page with pieces that I fill in from looking up an id in a database. So on my home page I have an url that looks like this: <a href="content/display.php?id=id1"> And then in my display.php I have this: <?php include '../includes/header.php'; $i...

Cannot redeclare class Zend_Loader_Autoloader

Hello, I am using Zend Debugger to debug my php application built based on the Zend Framework. Currently I am running the 1.10.6 version. When debugging my application i Get this error: Compile Error: /var/www/Zend/ZendFramework-1.10.6/library/Zend/Loader/Autoloader.php line 36 - Cannot redeclare class Zend_Loader_Autoloader Is this...

Allow only one br in nl2br

Hi, I let my members of my website to post some information about them in textarea. I use function nl2br to be it more prettier, smth like that: $text_of_area = nl2br($_POST['text_area_name']); //yeah, of course i use functions against xss, sql injection attacks mysql_query("..."); //here I insert a text But here is problem. I ...