php

How do i use the DIRECTORY_SEPARATOR for Windows

I am trying to figure why I am getting this error. **Warning: require_once(\C\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\config.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\initi...

How can I show some links/navigation to logged in users in wordpress?

Hello everyone, I need help with wordpress. I will show a login box on my main page and if some registered user logs in, I want to show some links/navigation to that person only (not to guests). Is that possible? If yes then how? Please guide me with. Thanks ...

PHP - temporary variable

Hi I have a function that retrieves some data from the database, formats it as html and then stores this html into a variable, $output. The problem is that $output cannot be echoed on the screen now, only later, after other functions run. Also this data must be retrieved at this stage, not later. so how can I call this $output variable...

Using PHP Oauth PECL Library to download files

I'm using PHP Oauth PECL Library to access audio files on Soundcloud and I'm not sure of the best way to do this. What I have so far is: $oauth = new OAuth( $network->get_consumer_key(), $network->get_consumer_secret(), OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI ); $oauth->setToken('', ''); $oauth->fetch('', array...

Handling missing array offsets

Consider the following piece of code: $tests = array( array ("a", "b", "c"), array ("1", "2", "3"), array ("!", "@") ); foreach ($tests as $test) test($test[0], $test[1], $test[2]); function test($param1, $param2, $param3) { // do whatever } This will work with no issues until it gets to the $test[2], which of course doesn't ha...

How do you handle charitable contributions?

Basically, I'm wondering if any of you have put together a for-profit e-commerce site that has had a charity donation option. We are trying to keep it a separate entity from our inventory and the rest of our books. We are looking for a tool to easily integrate a $1 or custom amount donation into the checkout. We run a single-page AJ...

Trouble posting HTML as variable in Curl

I am using CURL to post an array. It didn't work without using http_build_query(). I set one of the rows in the array like this: $postVars['key']=' <table style="border-style: solid;" width="850" align="center" bgcolor="#e9e9e9" border="3" bordercolor="#999999" cellpadding="0" cellspacing="0"> <tbody><tr> <td colspa...

I want to refresh a form after posting it back to itself with php or ajax.

My project is a bistro menu, using PHP and MySQL. It prints out a pretty table of menu items, as long as they are in stock. I made addRemove.php to add and remove items from the menu. It creates a button for each item, on or off. Items that are 'on' are in stock and displayed on the menu. When the user clicks a button, it will post the...

replacing first few digits with #

I want to hide the first 6 digits of social security I have them like 123-456-7890 I want to show ###-###-7890 how can I do that thanks ...

PHP: Can't change 404 status code, but there is no error from header()

I'm processing unavaliable pages in my custom PHP website. To do this I created a .htaccess file with this single line: ErrorDocument 404 /index.php At the beginning of index.php I placed this code: header($_SERVER['SERVER_PROTOCOL'].' 200 OK', true, 200); This works perfect in my WAMP environment. I'm checking http headers, and it...

Json - Mysql Charset Problem

I convert my php array to json using json_encode, Than I record this json data to my database .While json_encode encodes my data , It also converts strings to utf8 , this changes special characters to something like '/u011f' or '/u0131' . But when I write this converted data to mysql database , Backslashes are disappearing in field, so ...

PHP Error, syntax error T_STRING!

Hi, I get the following error; Parse error: syntax error, unexpected T_STRING in D:\XAMPP\xampp\htdocs\site\register.php on line 95 Line 95 is; if (strstr($email, "@") && strstr($email, ".") strlen($email) >=6)) Please help, I don't know what's wrong :/ It all looks fine to me. Thanks In Advance! ...

dynamically adding sets of form elements n times

i'm working on an application that lets users enter the opening hours for a restaurant. i have the form code set up like this: <div class="hourswrapper"> Days: <input type="checkbox" name="day1[]" value="1" />M <input type="checkbox" name="day1[]" value="2" />Tu <input type="checkbox" name...

Fgetcsv initial line reading problem

I'm working with a CSV file and PHP5 however I'm not quite understanding what I am seeing. The file is as follows when I open it in a text editor: "Jun 23,2010 21:40","City1","Location1","0 0 0 " "Jun 23,2010 21:41","City2","Location1","0 0 0 " What I get as output from this code: while (($data = fgetcsv($handle, 1000, ",","\"")) !=...

Need to reverse this regex pattern, but no clue how...

I found a regex pattern for PHP that does the exact OPPOSITE of what I'm needing, and I'm wondering how I can reverse it? Let's say I have the following text: Item_154 ($12) This pattern /\((.*?)\)/ gets what's inside the parenthesis, but I need to get "Item_154" and cut out what's in parenthesis and the space before the parenthesis. ...

save BLOB image to disk from database in PHP

I have stored an image in my database as a BLOB file. This might not be the best practice (I know this). I wanted to create a link on my page when clicked with prompt the user with the typical save file prompt so they can save the file on their personal disk. I have researched online but what I am trying does't not seem to work it just ...

tokenizing a metafield.

I am working with a CMS like system, which has a special field defined for use in its forms. This field works similarly to google suggest, executing an sql query behind the scenes and displaying results. The SQL query I am using selects 3 fields from table1, and concatenates them as a result. What I need to do, is split this new metaf...

PHP/HTML/Javascript: How to add value to a div element?

My Problem was: Add a value to a div element in a dropdown list. Ok Guys, I've resolved my problem with the help of @David. I've always wanted to know how to design the <select> <option> tags, but now I think I found a solution to get away from them and use whatever element I want. Ok here is my code: <!DOCTYPE html PUBLIC "-//W3C//DT...

PHP Looping through half the array

So i have an array that contains 100 elements foreach($obj as $element){ //do something } I want to loop through the first 50 but the problem is sometimes the $obj array maybe less then 50 ...

PHP cURL problem from local

Hey all, Quick question : I have a PHP script which query Pinnacle Cart API through a cURL query. While testing this on my laptop, no problem. I get the XML response and all. But once it's on the remote server... I get no result. I checked beforehand to be sure cURL was installed on the remote server, and it sure is. I don't have the sa...