php

Another simple "if-else" form in PHP?

Hi, i read somewhere before, there is another way to perform the if-else statement, the code should be similar to this: <?php $var = "stackoverflow"; // Here is the if-else if(strlen($var) > 1) ? echo "TRUE" : echo "FALSE"; ?> I could only remember something like this, but it doesn't work, anyone knows how to write this 1 line i...

php exec and shell_exec not working

I want to run an exe file on my server and return the output to the browser screen. The exe file takes a input file and then returns data on the screen. Why is this code not working? $output = shell_exec('myprogram < INP.DAT'); echo "<pre>" . var_export($output, TRUE) ."</pre>\\n"; It displays "NULL" on the browser screen. I have als...

select with likewise data

I have a table in database that is having some fields one of which is 'action' action is having data like bse-similar,bse-action.....nse-similar,nse-action...etc. now i want to fetch the data that is having 'bse' in its action field. How can i do that in mysql????? One more thing i want to copy this data to another table.How can i do...

PHP - can't send email to addresses at my own domain

I have a simple php script on my domain that sends me an email: ... $toMail = "[email protected]"; //this works - I get the email at my gmail $toMail = "[email protected]"; //this doesn't - I get nothing mail($toMail, $subject, $message, $header); What setting to I change to fix this? ...

Display c++ code in php

I am trying to display the contents of a .cpp file in php. I am loading it using fread when I print it out it comes out formatted incorrectly. How can I keep the format without escaping each character? ...

Ldap_add() : Invalid Syntax

I have a program here that uses the ldap_add, when i try to run the program, it displays an error: Warning: ldap_add() [function.ldap-add]: Add: Invalid syntax in /var/www/suey/costcenter.20090617.php on line 780 My lil' code here is: $ldapservers='ourServer'; $ds = ldap_connect($ldapservers); if ($ds){ $r = ldap_bind(...

RTF Library - PHPrtf Has anyone used it?

For some reason, my line breaks in my test.txt file are not being preserved. $sect->writeText(file_get_contents("test.txt"), $times12, $null); Has anyone played around with this library? http://sourceforge.net/projects/phprtf/ My question is: How can I preserve my line breaks from my test.txt file? What is happening is the docum...

Difference between using from list and left join.

I have two database tables with the following structure: actions: action_id int(11) primary key action_name varchar(255) action_module varchar(45) permissions: perm_id int(11) primary key perm_role int(11) perm_action int(11) perm_status int(11) Now I have to check whether there is an entry in the permission...

Displaying an image from a URL returned by an API

I am making an API call that should return something like the following, <?xml version="1.0" encoding="utf-8" ?> <Chart:chart xmlns:Chart="http://www.zillow.com/vstatic/3/static/xsd/Chart.xsd"&gt; <request> <zpid>48749425</zpid> <unit-type>percent</unit-type> <width>300</width> <height>150</height> </r...

How to enable users from another domain to search records from my domain?

Hi On my website users can keyword search and find desired results. (Just a simple keyword search, WHERE word LIKE %abc% OR LIKE %cde% etc etc). This all works fine. I have some partner websites which want to put a search box on their website to search records from my website and display on their website. We are using PHP and MYSQL....

Undefined variable in PHP but I've defined in the HTML page

Hi, I'm learning PHP to create a feedback form. I followed a tutorial and created a html page with the form and a php file to execute the request and save it into the database. Strangely enough, I've got two problems. And after I pressed the submit, I've got the following error: Undefined variable: user in /Users/wj/Sites/all_sanbox/VT...

MySQL Session Table Approach

Hi all, I am developing a multi-tenant web application using LAMP. All my user session data is currently stored in mysql with table type InnoDB. Is there any way that I can use MEMORY (used to be HEAP) table type to store the current sessions and use the garbage collector function of the session handler to move sessions between the Inn...

return javascript code full of 's, "s and \s from within a class, how can I do it?

I have a very long javascript (so long that it's too long to escape manually every single problematic character) that I need to return from a method inside a class. Are there way to return (return not echo or print) safely this kind of code? Thank you very much ...

Using an array for GET variables

I am currently using the following code for Get variables, and would like to know the best way to convert to an array. Is the main advantage of doing this just aesthetic, or is there a performance/efficiency aspect as well? if (isset($_GET["cmd"])) $cmd = $_GET["cmd"]; else die("Invalid URL"); if (isset($_GET["username"])) { $usern...

Build a Ranking

I have a newssystem where you can rate News with 1 to 5 stars. In the Database i save the count, the sum and the absolute rating as int up to 100 (for html output, so 5 stars would be 100 1 star would be 20percent. Now i have three toplists: Best Rated Most viewed Most commented Last two ones are simple, but the first is kinda tricky. B...

Variable naming conventions in CakePHP

What is the best way to name variables which contain multiple words? After going through lots of projects available in the CakePHP forge, I have noticed people use either camelCase, underscores or camelCase for variables and underscores for data sent to the view. An example of the last one would be: $activeSites = $this->Site->find('al...

Importing MD5+Salt Passwords to MD5.

I'm moving my site from an oscommerce store to a commercial application. The new application stores its passwords using straight MD5 encryption. Oscommerce stores the password using MD5, but also adds a random 2 digit number (provided in plaintext) to the hash. Here is what someone posted on a forum: The two characters added are ...

How to set up a method of easily managing multiple websites?

I have similar instances of the same web application running across many domains. I need an easy way to manage (edit, add, etc.) certain files (php, css, html) for each domain. I was thinking of writing a control panel in PHP, but was wondering if there are existing scripts people have already written for accomplishing this? Thanks! ...

PHP acts differently depending on computer

I have an issue with php where code works on on computer but wont work on another function appendParam(&$req, $name, $value) { if (req == null) { return; } if (name == null) { return; } if (value != null) { $req[$name] = $value; } } The above works on one computer and is capable of checking req and name against null pr...

PHP - Serialize floating points

Hi, I am generating 10 random floats between 6 and 8 (all for good reason), and writing them to a mysql database in a serialized form. But one quirk seems to emerge at the storage time: Before storing I'm just outputting the same data to see what it looks like, and this is the result I get a:10:{i:0;d:6.20000000000000017763568394002504...