php

Why is my regex removing spaces?

$str = "& &svnips   Â ∴ ≈ osidnviosd & sopinsdo"; $regex = "/&[^\w;]/"; echo preg_replace($regex, "&", $str); I'm trying to replace all un-encoded ampersands with encoded ones. The problem is it's removing the space between & and sopinsdo. Any idea why? ...

Validating a form for email exploits is not working

Hello, I have a contact form in my website. I made a class to handle the whole process. But there is something not working in it. I have 2 functions to check for exploitation and they are not working. I don't know what's wrong with them, so here they are : private function _validateExploit($val) { $exploitPattrens = array('conten...

PHPMailer: SMTP Error: Could not connect to SMTP host.

Hi There, I've used PHPMailer on several projects but now I'm stuck. It gives me the error: SMTP Error: Could not connect to SMTP host. I've tried sending email from Thunderbird and it works ! But not through PHPMailer ... Here are the settings from Thunderbird: Server name: mail.exampleserver.com Port: 587 Username: user@exampleser...

Convert XML elements to an array

I have some simple XML which I would like to parse into an array in PHP so that I can build some dynamic SQL inserts. Sample XML: <Data> <Key>1</Key> <Column>Value 1</Column> <Column2>Value 2</Column> </Data> Data will be passed to PHP via http POST. What's the easiest way to do this? There should always be one instance ...

Magento - check if cms page

hey, i want to check via php if a page is a cms_page in Magento. I need diffrent breadcrumbs for cms pages, so im trying to this with a condition, but i have no idea how to or where to look at. Heres my breadcrumbs.phtml so far. <?php if(this is a cms page): ?> <p>some content</p> <?php else: ?> <?php if($crumbs && is_array($crumbs)): ...

PHP JPEG Functions Not Working

Any PHP functions that deal with JPEGs don't seem to be working on my server. This code: <?php $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); header('Content-type: image/jpeg'); imagejpeg($im); imagedestroy($im); ?> creates an e...

php, MySQL and variables containing å, ä and ö escape problem

Hi. I'm having some problem with my SQL syntax/escaping variables on my LAMP server. The command I want to use is the following: $sql=mysql_query("INSERT INTO '$table' (FirstName, LastName, StartDate, TimeStroke, DueDate, Duration, Price, Retailer, Checksum) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[startdate]','$_POST[tim...

Is there something like Ruby's Treetop for PHP?

Hi, as I wrote a small PHP framework with a DSL parser, and I'm not satisfied with the result, is there any tool like Treetop for PHP? It would lead to far better (and nicer) results. ...

Zend Framework where is version 1.8?

Hello, I'm currently trying to improve my PHP by moving towards an MVC framework architecture. I've looked around a lot and have decided to go with the Zend Framework. However all the tutorials I can find talk about version 1.8, the problem is I can only find version 1.1 on the Zend Framework site. I'm probably missing some key concep...

ZF - Authenticate and submit remote form

How to authenticate to remote site via HTTP and then submit one more form, accessible only for authenticated user? What I'm trying to achieve: Login to Mantis bug tracker: http://www.mantisbt.org/demo/login_page.php Submit new issue: http://www.mantisbt.org/mantis/bug_report_page.php Logout: http://www.mantisbt.org/mantis/logout_page....

User-based dynamic permissions with Zend_ACL

Is it possible to assign users individual permissions based on dynamic elements in a Zend Framework application? I have tables like so: clients (id, name, contact_name, contact_number, logo, active) modules (id, client_id, module_id, active) permissions (id, user_id, client_id, module_id) users (id, username, password, email, realname)...

Warning: mysql_query(): 10 is not a valid MySQL-Link resource

I got "Warning: mysql_query(): 10 is not a valid MySQL-Link resource" referring to a line in my PHP script where I executed a query using "mysql_query($query, $link_identifier)" ...

PHP Syntax issue with headers

Can't seem to get it right with the syntax: <?php if isset $_POST['tutorial'] { header('Location: /phonebooks?tutorial=1b'); } else { header('Location: /phonebooks?phonebook_created=1'); }; ?> What am I doing wrong?? ...

Add to an array value (+1)

Hello, I have an array $hourly = array( "01" => "0", "02" => "0", "03" => "0", "04" => "0", "05" => "0", "06" => "0", "07" => "0", "08" => "0", "09" => "0", "10" => "0", "11" => "0", "12" => "0", "13" => "0", "14" => "0", ...

Adding JS To Codeigniter Links - Simple OnClick

I am trying to write a simple Javascript snippet into a Codeigniter link. I am using the link to delete posts where required in my dashboard. I dont know anything about JS although am trying to learn it. Code $js = 'onClick = "alert("Are you sure")"'; $this->table->set_heading('Date', 'Title', 'Delete', 'Update'); foreach($records ...

dompdf: seems to stumble over an <a> tag with <em> tags inside it

Hey StackOverflow, I'm a new member but still hoping someone might be able to help if they can! I'm using dompdf to generate PDFs in PHP. All is well when it parses a standard <a href="...">[Link]</a> style link: the generated PDF contains clickable hyperlinks. However, my source text (i.e. the content of the PDF) contains anchor tags ...

mysql/php insert/update on duplicate key

I have a product info table with more than 130 columns/fields. I want to write a php script that adds a new product to the table OR updates the existing product if it already exist. The first field is the product key. The product information is stored in a numbered php array : $product_info[0] to $product_info[130]. Basically somethin...

php form security

I was reading an article about form security becuase I have a form which a user can add messages. I read that it was best to use strip_tags(), htmlspecialchars() and nl2br() Somewhere else said to use html_entity_decode() I have this code in my page which takes the user input <?php $topicmessage = check_input($_POST['message']);...

array stored as string back into array?

hello - just trying to add some setting for the admin in a database entry. i've saved; array('aviva'=>'aviva','teacher'=>'teacher'); into the field 'fullPara' but can't seem to get it back into an array? Just spits it out as a string and i've tried eval but not sure where to go from here? echo $userTypes['fullPara']; // spits out a...

Way to gzip files like CSS, Javascript once and save them for serving to client instead of processing and gzipping every time a request is made

I believe this would be a more CPU friendly method, can it be implemented with php ?, instead of gzipping content for every request, I compress the files once and serve those instead =). ...