php

How to store lightweight formatting (Textile, Markdown) in database?

I'm going to be implementing a lightweight formatting language (probably Textile, maybe Markdown) in a project I'm working on, and I'm wonder how best to store it in the database. If the user is able to edit the content they're posting, it makes sense to me that the original, non-converted markup be stored so that the user doesn't have ...

Looking for a PHP/Ajax/MySQL code snippet to add/edit tags - same as stackOverflow

Hi, I'm in the middle of adding a tagging system to my website. I want to be able to easily add/edit items tags. My current tags table structure is: Table: Item Columns: ItemID, Title, Content Table: Tag Columns: TagID, Title, Tag_Counter Table: ItemTag Columns: ItemID, TagID I really like the implementation of the tagging in Stac...

How can i insert large files in mysql db using php?

Hi! I want to upload a large file of size 10M max to my mysql database. Using .htaccess i changed the PHP's own file upload limit to "10485760" = 10M, i am able to upload files upto 10M size without any problem. But i can not insert the file in database if it is more that 1M in size. i am using file_get_contents to read all file data ...

CakePHP XML loading

Hey all, I am using the CakePHP XmlHelper to parse XML files like: App::import('Xml'); $file = "my_xml_file.xml"; $parsed_xml =& new XML($file); How can I use it to load XML files from URLs like http://www.site.com/file.xml Thanks! ...

How to insert large files in mysql database using php?

Hi! I want to upload a large file of size 10M max to my mysql database. Using .htaccess i changed the PHP's own file upload limit to "10485760" = 10M, i am able to upload files upto 10M size without any problem. But i can not insert the file in database if it is more that 1M in size. i am using file_get_contents to read all file data ...

Do PHP jobs tend to be in non-corporate/ stuffy environments?

Please excuse the subjective nature of this question but I'm trying to determine whether to focus on PHP for my next job search because I'm looking for a less formal work environment. Do I have an impression that PHP jobs tend to be in less formal work environments such as smaller companies/startups with more of a progressive attitude? ...

variable length packets in php

I am receiving packets sent to my server through UDP. I am using socket_read to read the data and it is coming along just fine. I have run into an error however. The length parameter to socket_read in my case is NOT always the same. The length of the data can range anywhere from 50-150 bytes. One thing that remains constant is that the d...

Include file_exists safety

/* define page path */ define("PAGE_DIR", "pages/"); if (file_exists(PAGE_DIR."$_GET[page].php")) include(PAGE_DIR."$_GET[page].php"); How safe is this? Could you for example include a page on another webserver if the page is in a folder called pages? Thanks ...

Best way to use a postgresql sproc (returning ref cursor) with PHP ?

Hi. I'm using stored procs and call them from PHP (I use the same procedures in a Java app too). Right now I do it this way (which works): if(!($result = pg_query($connection, 'BEGIN; SELECT '.$query.'; FETCH ALL IN '.self::$cursor.';'))) return NULL; where $query is something like "CALL create_account('foo', 'bar', 'etc')" and $cu...

Is it possible to set a cookie for a site /server other than you own?

Here's the quick version of my question: Is it possible to set a cookie somehow into a client's browser when the cookie is for use with a different server (in this case an Exchange mail server)? In this scenario the server trying to set the cookie is at "intranet.myschool.edu" and the exchange server is at "owa_server.myschool.edu". ...

PHP/Django/Rails/Flex hybrid demo - need project idea

Let's say you were crazy enough to want to try to combine a number of different technologies just to show that you could do so - what kind of app would lend itself to this type of project as a demo for a potential employer? Specifically I'm thinking of combining the following technologies: PHP/Django/Rails/Flex Does this sound ridicu...

How different is CakePHP from Ruby on Rails?

I almost never hear the word CakePHP without hearing the word Rails shortly afterwards. Are these two frameworks mainly similar based on how they adhere to the MVC model or do they have other significant similarities/differences? One of the main attractions of Rails for me is how easy it is to do Ajax. Would that also be true of CakePH...

Login Script problem

if (isset($_POST['login'])) { $query = mysql_query(" SELECT id FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."' AND password = '".mysql_real_escape_string($_POST['password'])."' "); /* wrong login information? output a message and terminate the script */ if (!mysql_num_rows($que...

Function vs Objects Best Practice

Hi, I am wondering whats the best practices regarding functions and objects. For example I want to perform an action called tidy. It will take my data as input and tidy it and return it. Now I can do this in two ways. One using a simple function and the other using a class. Function: $data = tidy($data); Class: $tidy = new Tidy(); $da...

Website got Hacked? Site got redirected

my friend's website got hacked somehow. The index.php page got inserted an extra line of javascript, which redirect the page to another website. The index.php is just a text file not managed by any CMS. he has changed all ftp/ssh user password. Somehow this is still happening. Any hint on what might be the cause? ...

Does most professional PHP development take place on PCs or on Macs?

I'm trying to determine how likely it is that my next job will involve the use of a Mac/PC if I am hired as a PHP programmer. With Rails, most shops seem to develop on the Mac. I'm wondering whether the same is true of PHP. ...

The select element should return 2 values.

I have a select box with options in it. The value of the options gets the id of the item that is displayed in each option. I do have an other value that should be linked on this option. Is there an easy way to do this? <select id="category" name="data[cat]"> <option value="12" label="0">A</option> <option value="7" label="0">B</option...

scrambling letters php

i would like to scramble all a-zA-Z so a world like hello becomes shrxs or bhidf the rest should stay the same. eg. "hello world!"="ksgii fishl!" etc. ...

How to redirect to different admin page in Wordpress?

Hi I am writing a Wordpress plugin. I want to perform a redirect (after creating DB records from POST data, etc...) to other ADMIN page. Neither header("Location: ...) nor wp_redirect() work - i get Warning: Cannot modify header information - headers already sent by which comes from obvious reason. How do I properly perform a red...

mysqli bind variables

Hello, I have this partial code: if ($getRecords = $con->prepare("SELECT * FROM AUCTIONS WHERE ARTICLE_NO = ?")) { $getHtml = $con->prepare("SELECT ARTICLE_DESC FROM AUCTIONS WHERE ARTICLE_NO = ?"); $getHtml->bind_param("i", $pk); $getHtml->execute(); $getHtml->bind_result($ARTICLE_DESC); $getRecords->bind_param("i", $pk); $g...