php

Mysql Real Escape String PHP Function Adding "\" to My Field Entry

Hello, I am submitting a form to my mySql database using PHP. I am sending the form data through the mysql_real_escape_string($content); function. When the entry shows up in my database (checking in myPhpAdmin) all of my double quotes and single quotes are escaped. I'm fairly certain this is a PHP configuration issue? so: $c...

How do I strip quotes from an input box using PHP

I have this: <input name="title" type="text" class="inputMedium" value="' . $inputData['title'] . '" /> I want to strip quotes from user input so that if someone enters something like: "This is my title" it wont mess up my code. I tried this and it's not working: $inputData['title'] = str_replace('"', '', $_POST['title']); ...

What are the options for Doctrine's addColumn() migration method?

The API gives the code as: public function up() { $this->addColumn('table_name', 'column_name', 'string', $options); } but there's no documentation for what can be included in the options array. http://www.doctrine-project.org/Doctrine_Migration_Base/1_2#method_addcolumn ...

Need a zip locator feature on a site. Where to start?

Hey guys! So I have been tasked to create a site which has a dentist locator based on the zip code inputted. There will be 8 dentists that will be available. I will probably set up a table in a mysql database to hold the information on the dentists (more will be added in the future). I just don't really know how to get started. I kno...

Do I have to use mysql_real_escape_string if I bind parameters?

I have the following code: function dbPublish($status) { global $dbcon, $dbtable; if(isset($_GET['itemId'])) { $sqlQuery = 'UPDATE ' . $dbtable . ' SET active = ? WHERE id = ?'; $stmt = $dbcon->prepare($sqlQuery); $stmt->bind_param('ii', $status, $_GET['itemId']); $stmt->execute(); $stmt->close(); } } Do I need to mysql...

Zend DB fetchAll(): where clause array with IN operator

I'm selecting records from a database using the equivalent of this query: SELECT * FROM reports WHERE user_id IN (3, 6, 22); The function calling fetchAll() has an argument that's an array of the user IDs, and this call works just fine: $resultSet = $this->getDbTable()->fetchAll('user_id IN (' . implode(', ', $userIds) . ')'); Howe...

Extracting XML with PHP

I know how to use simplexml_load_file to get XML results if the XML format is <bowlcontents> <banana>yellow</banana> <apple>red</apple> </bowlcontents> However, I have some code that is in the format <bowlcontents> <fruit type="banana" skin="yellow" /> <fruit type="apple" skin="red" /> </bowlcontents> and I want to mani...

Problem with PHP PEAR Mail

I am trying to use PEAR Mail to send using an external smtp server. It seems to hang for a while, then the script ends. It outputs all of my "echo" statements up till the one after the send. Nothing is output past the echo that says "before send". Can anyone tell me what might be wrong here? (dummy values substituted for smtp values). Ma...

How to access class members from an array of class variables?

I want to use PHP's reflection features to retrieve a list of parameter names from a method. I have a class like this: class TestClass { public function method($id, $person, $someotherparam) { return; } } I can get the list using code like this: $r = new ReflectionClass('TestClass'); $methods = $r->getMethods(); for...

Paginate text file with PHP

I have a small script that displays blog posts from a text file, how can I add pagination so that it only shows 5 blog posts at a time? Here is the script: <html> <head> <title>blog</title> </head> <body> <?php $mode = 0; if ($mode == 0) { $opFile = "blogfile.txt"; } $fp = fopen($opFile,"r") or die("Error Reading File"); ...

How to show unread subforums?

I have written a simple forum in PHP using PostgreSQL. The forum consists of a number of subforums (or categories, if you like) that contain topics. I have a table that stores when was the last time a user visited a topic. It's something like this: user_id, topic_id, timestamp. I can easily determine what topics should be marked as unre...

php-excel-reader not displaying format of empty cells

I'm working on a little app that takes Excel spreadsheets that display tournament brackets, and then output the excel data and formatting into xml. I'm using Spreadsheet_Excel_Reader h(ttp://code.google.com/p/php-excel-reader/) to retrieve the data from the tournament bracket spreadsheets. The only problem is that any cell will no valu...

Best method for selecting multiple checkbox items

I am developing an internal messaging application which is to be used by approximately 500 users. When composing a new message it will ask who you want to send the message to. Instead of presenting the user with a checkbox list of 500 users which they can pick from (i.e they may only wish to send to 20-30 of the 500 users) I wanted to as...

Undefined index pass variable with javascript to php

Hello. I am making an "updating" pages with JS jquery.. But in my updateit.php i just get Undefined index on all my fields. I dont know why. Here's the form: <form action="javascript:updateit()" method="post"> <b>+ Giv points for at være online:</b><br> Points hvert. <input type="text" size="1" id="gpe" name="gpe" value="<?=$row["gpe...

php setcookie domain

Some application, not written by me, and not in PHP, creates a cookie for the domain "www.domain.com". I am trying to replace that cookie. So in php I did: setcookie('mycookie','mydata',time() + 2*7*24*60*60,'/','www.domain.com', false); However the resulting cookie is created for domain: ".www.domain.com", note the dot "." ahead of ...

Why do I keep getting php error saying unexpected ')' in FOR statement?

I am programming an HTML 10x10 table, Each cell with a separate ID and link. It was taking way to long with copying and pasting and changing so I decided to use PHP, using the FOR command which I am not very familiar with. I am using this code: <table> <?php for ($r=1, $r<10,$r++) { ;echo "<TR>"; for ($d=1, $d<10,$d++) { echo "<TR id=...

Trim doesn't remove \n

I am taking a string from textarea and exploding it and trimming each line of the array with array_map(): $answers = explode("\n", $data['answers']); // remove all whitespace such as \r (carriage return) $asnwers = array_map('trim', $answers); Then I store each array value in a separate row in a table answers in the database. The prob...

How do I process jpg files using ImageMagick (IMagick API)? I am getting an exception, NoDecodeDelegateForThisImageFormat, whenver I try.

I am using ImageMagick with the PHP IMagick API to process uploaded jpg files - however, when I try to read a Blob or even read a physical file, I get the exception, NoDecodeDelegateForThisImageFormat An example of the code I am using is below - private function resizeImageBlob($blob, $width, $height) { $image = new Imagick(); ...

redirect page to difference server in php

Does anyone know the code used for redirect page to difference server in PHP? For example: I have 3 server here called server_1, server_2, server_3. and I would like to redirect a page abc.php to server_2. How should the code look like in php? ...

PHP - smart, error tolerating string comparison

Hello, I'm looking either for routine or way to look for error tolerating string comparison. Let's say, we have test string Čakánka - yes, it contains CE characters. Now, I want to accept any of following strings as OK: cakanka cákanká ČaKaNKA CAKANKA CAAKNKA CKAANKA cakakNa The problem is, that I often switch letters in word, and...