php

Persisting complex configuration to a file (PHP)

I have a fairly large MVC PHP web app (custom, no framework) that uses a several-hundred-line XML file for configuration. The config data has a fairly complex structure, which is very elegantly represented in XML but not so easily read or written using the DOM. All reading and writing of config data goes through a Config class, which has...

Is storing image paths in a database necessary?

First, I noticed there are many questions regarding this, lots marked as duplicate. I eventually came to this one. And the accepted answer for that question although partially solves my question, it doesn't answer all of it. My question is, a user uploads an image. I store the path in the database and the image file in the file system...

.htaccess and $_GET rewrite

Hi, I am having an annoying issue. I have a script which uses the $_GET feature of php to get a variable from the url of the page. However, I need to know how to, first and foremost, make my page url go from http://www.example.com/dir/dir2/page.php?value=something&anothervalue=somethingelse to http://www.example.com/something/...

How to skip arguments when their default is desired

If I have a function like this: function abc($a,$b,$c = 'foo',$d = 'bar') { ... } And I want $c to assume it's default value, but need to set $d, how would I go about making that call in PHP? ...

Newbie, while loops

header $id = intval($_GET['id']); $query = mysql_query("SELECT * FROM table WHERE id = $id"); view while ($row = mysql_fetch_array($query)) { $column1 = $row['column1']; $column2 = $row['column2']; $column3 = $row['column3']; echo $column1....... } How can I keep the above code in my header file? So my designers wont have to s...

Outputs all minus one

I use this code to output all threads with a specific forum ID $query = mysql_query("SELECT * FROM forums JOIN threads ON threads.fid = forums.id WHERE forums.id = ".intval($_GET['forumID'])); $forum = mysql_fetch_assoc($query); ?> <h1><a>Forums</a> &gt; <?=$forum['name']?></h1> <?php while ($thread = mysql_fetch_array($query)): ...

Help with Pagination

How would I do to bold the page I'm on and make it unclickable? In the link at the bottom? If I'm on page 3 for example: 1 2 3 4 This script: // how many rows to show per page $max = 15; $page = $_GET['page']; // if $page is empty, set page number to 1 if (empty($page)) $page = 1; $limit = ($page - 1) * $max; $sql = mysql_query("...

How can I set the number of ticks with Image_Graph?

I am using Image_Graph (maintained at pear.veggerby.dk)to generate some graphs. I've been trying to use the methods described on this page http://pear.php.net/reference/Image_Graph-0.2.1/Image_Graph/Image_Graph_Axis.html to manipulate ticks but none of them seem to even exist in the 0.7.2 install. Anyone else having this problem? ...

AJAX on localhost using IIS and php and MySQL

I am trying AJAX for the first time on my localhost. I am using IIS and PHP with MySQL. This error is generated: "A HTTP Error 404.3 - Not Found" when I try this javascript command: xmlhttp.send(null); xmlhttp is a varable and is used to retrieve the GetXmlHttpObject ...

PHP Installer Script

I'm looking to create a fully functional installer for a slightly complicated web application using PHP. Basically, you go to URL/setup.php and you are asked a series of questions, and during the process a database is set up and a config file is populated according to the answers given. A good example of this is how Wordpress handles i...

MySql driver not installed error for Zend application

I am trying to get my ZEND application up on my apache server running on UNIX. Initially my host didnot give PDO support ,and i got it enabled by requesting them with a mail.But now I am getting an error saying The mysql driver is not currently installed The stack trace is like: An error occurred Application error Exception informatio...

How to integrate PHP_Beautifier into NuSphere PHPed IDE ?

Hello Can anyone list the steps to integrate PHP_Beautifier in phped. ...

Setting up Paypal to connect to script

I have, I believe followed the set up instructions correctly for connecting paypal to my script.I have a game that is set up to let users buy credits. Right now I have to add the paypal info directly into the database. I get the transaction email, both me and the user confirming the purchase. But it will not show up in my database.Can so...

PHP: Regular Expression to delete text from a string if condition is true

Hi, I have a variable containing a string. The string can come in several ways: // some examples of possible string $var = 'Tom Greenleaf (as John Dunn Hill)' // or $var = '(screenplay) (as The Wibberleys) &' // or $var = '(novella "Four Past Midnight: Secret Window, Secret Garden")' I need to clean up the string to get only the first...

post data changing on submit

When I submit data in my form it changes "abcd" to \"abcd\" on the other end.How can I overcome this problem... (I am using post method to send data)..... Please help...Thanks ...

Simple SQL question

(I couldn't make up a good title, sorry) So I use this pagination: $page = $_GET['page']; $max = 5; // if $page is empty, set page number to 1 if (empty($page)) $page = 1; $limit = ($page - 1) * $max; $sql = mysql_query("SELECT * FROM posts ORDER BY date DESC LIMIT $limit, $max"); $totalres = mysql_result(mysql_query("SELECT COUN...

PHP License generator protection conflict with paypal IPN?

Hi world, I'm going to integrate a license key generator in my web site, in the way that It can automatically generate license keys when occurs a paypal notification (IPN)... but my question is: what is the best way to protect the php file (that contains the method used to generate the key) and the private (a .pem file)? Thanks in adva...

Variable speed of response with jQuery Ajax requests

When I perform an asynchronous request with jQuery Ajax, sometimes the response is returned quickly in 800 ms, somtimes it's slow and the response is returned in 2.50s (avg), and sometimes it hangs, and just shows the loading images. I'm not sure if it's because of my PHP code or jQuery Ajax code. I send some values using jQuery Ajax: ...

%u problem in PHP

Hello all, Characters such as "š" when sent in a POST parameter and echo'd come out as %u015F - now I know this a hexidecimal value of the html unicode character - ie &#351; but how do I go about converting these? I have characters sets set to UTF-8 and I've experimented with ISO character sets with no luck. Thanks! ...

How should I store textual data that won't change very often?

As an exercise in web design and development, I am building my website from the ground up, using PHP, MySQL, JavaScript and no frameworks. So far, I've been following a model-view-controller design. However, there is one hurdle that I am quickly approaching that I'm not sure how I'm going to solve, but I'm sure it's been addressed before...