php

pg_connect crashes my php script

I'm trying to run a PHP script which has pg_connect($connection_string) and it just crashes my PHP script. I'm running it off of xampp on my computer, here are some facts: If I put exit("test"); immediately above the pg_connect statement, it successfully displays the word "test" and terminates the script, so I know that my installation...

Debug MySQLs "too many connections"

I'm trying to debug an error I got on a production server. Sometimes MySQL gives up and my web app can't connect to the database (I'm getting the "too many connections" error). The server has a few thousand visitors a day and on the night I'm running a few cron jobs which sometimes does some heavy mysql work (Looping through 50 000 rows,...

Where and when to open a database connection

I am working on implementing use of the mysql class found here in an existing script. The script almost always needs to interact with the database, even if there are times when it does not. What is the best practice in this case? Should I open a connection and keep that open until the end of the script or should I open a connection when ...

Setting initial indent level for PHP in Emacs?

I typically code my PHP with one level of indentation after the initial <?php, but I'm having trouble finding a setting for this in Emacs with php-mode. To be clear, here's what Emacs is doing: <?php echo "Hello."; if (something) do_something(); And here's how I usually code: <?php echo "Hello."; if (something) ...

Need ways to speed up PHP methods

I ended up creating my own HTML class, mainly to keep all our output consistent. The code is below. <?php /** * A class to generate html tags * @author Glen Solsberry */ class HTML { private $isOpen; /** * holds all information about tags * @var $tags array */ private $tags; private $current_tag = 0;...

Changing the address of the website, as per the php being used.

I have a button in my abc.html page <input type="button" onclick="javafun();"> on the click it goes to javascript, which further send info to my abc.php ...and the javascript function looks like: function login() { xmlhttp=GetXmlHttpObject(); //alert("pass"); if(xmlhttp==null) { alert("Your browser does not s...

Odd PgSQL permission error

I'm having a really strange and frustrating issue. On one page, an existing and often used one, I have this query: SELECT COUNT(*) AS count FROM uvusers WHERE vdate IS NULL It works exactly as expected and always has. On a new page I'm working on, I have this query: SELECT COUNT(*) AS count FROM uvusers WHERE vdate IS NULL This gen...

How do I access node information from a view in Drupal

I have written a custom view template called "views-view-unformatted--FAQ.tpl.php. How can I access the nodes? The $rows array only holds the rendered content from the node.tpl.php template. Bottom line is this - I want to organize the FAQ's into sections by taxonomy. ...

Is there a way to use PHP code inside a smarty template?

I searched google, but coulding find anything. Checked the documentation too... I thought Smarty allowed PHP to be written inside the template itself if you escaped the template engine? ...

Cookie sniffer - PHP

I guys. Have worked around with cookies in PHP for some time. However something came to my mind. Does its possible to gather all cookies (without knowing its names), or at least list all cookies names present in a browser? Regards. ...

How can I preserve session information when redirecting from one subdomain to another?

I'm programming with PHP. I want to redirect https://abc.example.com/blah1/blah2 to https://www.example.com/blah1/blah2 but I don't want to redirect https://abc.example.com redirect to https://www.example.com Is it possible while preserving session information across the redirections? Thank you. ...

Mysql persistent connections and advantages of mysql_pconnect?

I had never heard of persistent connections before, and I don't understand the advantages. I run a PHP/MySQL based internet website, it receives tens of thousands of page views per day. In my header file on each of these pages I have just used mysql_connect() and I haven't bothered with terminating the connection in the footer file. In ...

Zendx JQuery Autocomplete

I've been trying to get the Zend Jquery autocomplete function working, when i noticed this section in the Zend documentation. The following UI widgets are available as form view helpers. Make sure you use the correct version of jQuery UI library to be able to use them. The Google CDN only offers jQuery UI up to version 1.5.2. Some o...

Get value from Multidimentional Array containing an Object

how can i get [user_id] from this array? Array ( [2] => cbpaidSubscription Object ( [replaces_plan] => [replaces_subscription] => [subscription_date] => 2009-07-14 12:45:52 [last_renewed_date] => 2009-07-14 12:45:52 [expiry_date] => 2010-07-14 12:45:52 ...

Can I dynamically generate a 300 dpi image from a flash file?

I'm using a compination of actionscript's getPixel and php's imagecreatetruecolor and imagesetpixel to generate a png image of an swf movie inside a browser. At the moment it will output a 72 dpi image at the same resolution as the swf movie, but I've been asked about the possibility of generating a 300 dpi image instead. Is this possi...

Is there any equivalent function that returns the character at position `X` in PHP?

Is there any equivalent function that returns the character at position X in PHP? I went through the documentation but couldn't find any. I am looking for something like: $charAtPosition20 = strCharAt(20, $myString); ...

Syntax Error with MySQL Query

Hey everyone, I am getting the following error and I have spent hours looking at it and cannot figure out why! ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary='doej2', secondary='1' WHERE id='2'' at line 1 Here is my code: <?php if (...

Differences between SQL Plus and "regular" SQL?

I'm new to the Oracle Platform (having primarily used MySQL, with a little Postgres and SQL Server as well). I recently discovered the following statment DESC TABLE_NAME; will only work in the SQL*Plus tool I use to test my queries. It will NOT work when I use PHP's standard functions to connect to the oracle database. I need to us...

What's a good way to manage error and success messages and codes?

Currently I don't have a very good system for managing error or success messages, they are pretty much written inline with the code. Can someone suggest a best practice or something you are doing to be able to properly manage a large list of error and success messages through out an application. Think internationalization ... some appli...

How to get all urls from page (php)

I have a page with urls with descriptions listed one under another (something like bookmarks/list of sites). How do I use php to get all urls from that page and write them to txt file (one per line, only url without description)? Page looks like this: Some description Other description Another one And I would like script's txt outpu...