php

phpmailer sends email out with the subject line added twice

There is a weird error in a very basic implementation of phpmailer in which the subject line adds itself twice, its only been added once in the code: $mailer->Subject = "My Subject"; $mailer->Send(); The output is that it gets the mail but with the Subject Line seen twice in the email client. Its very odd, and its not been set earlier...

php + download to excel --> worksheet name

Hi, I am currently exporting data from php to excel using the code as below: include("dbconnect.php"); $query = $_POST['query']; $result = odbc_exec($conn,$query); $count = odbc_num_fields($result); //Define Variable For ODBC $data = ""; //Field Name Data for ($i = 1; $i <= $count; $i++) { $data .= odbc_field_name($result,...

php & mySQL: Space taken up by a TEXT column

Hi all, I have a column with it's structure as TEXT. I would like to know how much space the 3 rows take up considering the following data in it against the TEXT column. TEXT column ROW1 ROW2 Hi ROW3 ABCDEFGHIJKLMNOPQRSTUVWXYZ... (really long, let's say 1500 characters) We have 3 rows above. Row1 is empty. Row2 has only 2 ...

Codeigniter image upload not working

I can't get my images to upload no matter what i do. Below is the code that is in my model: function do_upload() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('up...

How can I check with a regex that a string contains only certain allowed characters?

I need a special regular expression and have no experience in them whatsoever, so I am turning to you guys on this one. I need to validate a classifieds title field so it doesn't have any special characters in it, almost. Only letters and numbers should be allowed, and also the three Swedish letters å, ä, ö (upper- or lowercase). Besi...

PHP Trasnlate HTML page using google translate

Afternoon, Bit of a tricky question this one, I have a website and need to translate the pages into french, I am using google translate API to do the translation. What I am doing is loading in the HTML templates into a string using PHP and then need to translate the text copy on the pages and then save as for example: fr_master_header...

Strange PHP syntax

I've been working on PHP for some time but today when I saw this it came as new to me: if(preg_match('/foo.*bar/','foo is a bar')): echo 'success '; echo 'foo comes before bar'; endif; To my surprise it also runs without error. Can anyone enlighten me? Thanks to all :) ...

Learning PHP - start out using a framework or no?

I've noticed a lot of jobs in my area for PHP. I've never used PHP before, and figure if I can get more opportunities if I pick it up then it might be a good idea. The problem is that PHP without any framework is ugly and 99% of the time really bad code. All the tutorials and books I've seen are really lousy - it never shows any kind ...

Does this query fetch unnecessary information? Should I change the query?

I have this classifieds website, and I have about 7 tables in MySql where all data is stored. I have one main table, called "classifieds". In the classifieds table, there is a column called classified_id. This is not the PK, or a key whatsoever. It is just a number which is used for me to JOIN table records together. Ex: classifieds ...

oData and PHP without control of the server

B"H Is there a way to query oData from PHP without needing to change the php.ini? i.e. if I only have permission to upload files into the public web directory, and I do not have a shell account to run the scripts to generate the proxy classes, is there a way I can use curl directly to query an oData database? Or could I use only part o...

Split an array, not working

Hi OK I need to figure out how to count how many numbers are in the following example. 07000000000,07000000001,07000000002,07000000003,07000000004 etc... I have tried the following PHP functions. explode, implode, count, foreach and for. None of them seemed to have worked and I am really stuck now. Any help will is appriciated. Ky...

is PHP itself transforming into a framework or big library?

At the beginning PHP was a scripting language. But after the introduction and improvement of OOP I see more and more objects added to the core. They started with libraries like DOM (the PHP 4 and 5 varieties), later SPL which grew a lot, and the DateTime family which should be part of PECL, Pear or Zend Framework or implemented by each o...

abstract class extends abstract class in php?

I am working on a simple abstract database class. In my usage of this class, I'll want to have some instance be a singleton. I was thinking of having a abstract class that is not a singleton, and then extend it into another abstract class that is a singleton. Is this possible? Recommended? Edit: I want to have two abstract that are p...

PHP OOP: Unique method per argument type?

I'm writing a little homebrew ORM (academic interest). I'm trying to adhere to the TDD concept as a training exercise, and as part of that exercise I'm writing documentation for the API as I develop the class. Case in point - I'm working on a classic "getCollection" type mapper class. I want it to be able to retrieve collections of ass...

Regular expression for Regular expressions?

I have an app that enables the user to input a regular expression, my question is how to check against any input of regular expressions and make sure they are valid ones because if they are not there will be preg_match errors. I don't want to use the '@' before preg_match, so if there's a way to check the validity of the user input of r...

How do I make a page aware that the viewer is logged in or not?

I am building a membership site... I just got thru the login page and I can now login and logout. However that alone doesn't protect all my pages in the root.. How do I go about this? I'd like to set it up like so when the viewer isn't log-in, the page that's being opened would say "Log in first blah3x"... Any help pls??? :-( ...

Handling Errors in PHP

I have a custom class that, when called, will redirect to a page and send a 'message_type' and 'message' variable via GET. When the page opens it checks for these variables and displays a 'success', 'warning', or 'error' message depending on the 'message_type' variable. I made it so the user thinks they stay on the same page. It also all...

Get The value of text Field while form submit in php

how to get the value of input box while submitting the form in php i need the url like this www.example.com/te/?a=test&firstname=blabla <form action="te/?a=test" method="post"> <input type="text" name="firstname" /> <input type="submit" name="button" /> </form> ...

Add/remove Cake named URL parameter for a link

Using CakePHP 1.3 there are named parameters in the URL like .../name:value/... These are used for example by pagination links .../page:2/key:date/sort:desc/... How to generate links with HtmlHelper::link() adding/deleting such named parameters from the current URL? Basically I want create links to add/remove/modify the category:ID nam...

Email/Web server type discovery - using PHP or Perl

Fairly simple question (I think): I have a list of domains, and I want to loop through them, hitting their email and web servers, and determining the type of server software running. Something like this: LOOP over domain list ... Socket connect with www.[domain-name] over Port 80 ... Get return handshake volley of server type >...