php

How can I set a cookie and then redirect in PHP?

After doing a bit of processing, I want to set a cookie value to user input and then redirect them to a new page. However, the cookie is not getting set. If I comment out the redirect, then the cookie is set successfully. I assume this is a header issue of some sort. What is the best workaround for this situation? if($form_submitted...

How do I run a php script through SSH?

I have a rather long php script and whenever my internet connection skips out for a second the browser seems to stop the script. I can't sit around for 8 hours for my script to run so I figured I could just run it via ssh and be come back the next day and get my output file. However simple typing the scripts name into ssh doesn't seem ...

Recommend security training for PHP/MySQL web developer

Know any good courses, online or perhaps otherwise, you'd recommend to a relatively new PHP/MySQL web developer to get her up to speed on security vulnerabilities? It would be nice if it was fairly thorough and went beyond basic stuff like sql injection. Ideas? Edit: Thanks for the really great links and information, but I'm also loo...

Random line break showing up when .load() results display on page

I've had this problem for a while, and I've isolated it to being caused the mysql_connect or mysql_select_db function. For some reason, when I use jquery's .load(), the response text will have a line break at the top when displayed in the page (in a <textarea>, for instance, but in any element). Looking at the response in Firebug, there ...

SimpleTest: How to assert that a PHP error is thrown?

If I am correct, SimpleTest will allow you to assert a PHP error is thrown. However, I can't figure out how to use it, based on the documentation. I want to assert that the object I pass into my constructor is an instance of MyOtherObject class Object { public function __construct(MyOtherObject $object) { //do something with...

Setting a Php $_SERVER value ($_SERVER['something']) using Apache .htaccess

Is it possible using .htaccess or other apache powers to set a custom server value in the php array $_SERVER. for example if($_SERVER['is_special']) { echo "Yeah for us!"; } else { echo "No you fool!"; } I realize I ask a lot of questions that the answer is no so feel free to say so. ...

How can I configure the mail function of PHP on Windows Vista?

I am working on my own website. I am planning to have a mail function to send notification to the users who want to join my website. The problem is the mail function of PHP does not work for me. Can anyone help me with this? ...

How do I best process my multi-dimensional arrays in PHP?

I have an app that shows store sales. It is a multi-dimensional array, so each value in the root array is an array containing [sales], [cost], [date], etc. for the given day it pertains to. OK, there are 2 arrays for each store. One is for verified numbers and the next is for unverified numbers. The unverified picks up right after the ve...

When I try to GZIP .js files using PHP I get some kind of php related error.

Okay, So I've googled a couple of pages and come up with the following solution: Add this in .htaccess #Active GZIP for php-files php_flag zlib.output_compression On php_value zlib.output_compression_level 5 and this for .js and .css: AddHandler application/x-httpd-php .css .js php_value auto_prepend_file /Library/WebServer/Documen...

Multiple Inline Conditions AND OR vs ELSEIF

I think sometimes I don't need to use ELSEIF and not repeat stuff by maybe doing multiple checks inline. I've done this before. I'm trying this simple line and just can't make it work. I read that: OR is the same as || AND is the same as && Code (The short way, but doesn't work): if($subdom<>'www' or $subdom<>'nosub') {do some stu...

Does anyone know of a good site for beginning in YUI?

Does anyone know of a good site for beginning in YUI? The developer's manual on Yahoo is too confusing for me. ...

Rolling Your Own Plaintext Wiki (Wiki inside a DB)

Anyone know of an API (php preferable but I'd be interested in any language) for creating wiki-like data storage? How about any resources on rolling your own plaintext wiki? How do other plaintext wikis handle the format of the text file? I understand I can use Markdown or Textile for the formatting. But what I'm most interested in i...

AJAX live email validation (PHP)

When a user creates an account on my website, i want the inputted username to be checked against all the current usernames in my database(MySQL) and confirmed if it is available. Does anyone know any good libraries i could use, or a plug-in for JQuery perhaps? Thanks, Ben. ...

Business Weeks

I need a function in php that will calculate the business week in a specific format within a given date range. Example: startDate = 02-03-2009 endDate = 31-12-2010 Mar 2-6 Mar 9-13 Mar 16-20 Mar 23-27 Mar 30 - Apr 3 Apr 6 - 10 and so on... ...

Directory structure for a file host

I've got a simple file host going that gives files a unique id and just stores them in a directory. I've been told that this will cause problems in the future, and I'm wondering what things I should look out for to make sure it works smoothly into the future and beyond. Also, is there a performance issue with forcing downloads by sendin...

Have I covered all bases with security when echo'ing a server variable to the page?

With forms I've always used <form method="post" action="<?php echo strip_tags($_SERVER['REQUEST_URI']); ?>"> To get my forms to submit to themselves. I use striptags() in case someone links to: http://www.mysite.com/page-with-form.php?bla="&gt;&lt;script src="http://www.nasty.com/super-nasty.js"&gt;&lt;/script&gt;&lt;a href="# Hav...

How do PHP sessions work when cookies are disabled?

I've tried to research this mechanism but only find hints and these are not very consistent. How is the session _id sent to the browser and how is the browser instructed to return it when the user requests a new page? Thanks, Chris ...

cakephp - best way to make a dynamic menu

I want to display a menu on every page that is run from a database. Using just down and dirty php thats easy but I want to integrate it with cakephp using their MVC system. Now my question is how is the best way to go about this? My thoughts are to make an element with the layout and then a component or controller for all the logic. ...

Is Full Text search the answer?

OK I have a mySQL Database that looks something like this ID - an int and the unique ID of the recorded Title - The name of the item Description - The items description I want to search both title and description of key words, currently I'm using. SELECT * From ‘item’ where title LIKE %key% And this works and as there’s not much in...

Commands out of sync; you can't run this command now1

I am trying to execute my php code, which calls two mysql queries via mysqli, and get the titular error. Here is the code I am using <?php $con = mysqli_connect("localhost", "user", "password", "db"); if (!$con) { echo "Can't connect to MySQL Server. Errorcode: %s\n". mysqli_connect_error(); exit; } $con->query("SET NAMES 'utf8...