php

Apache Url Rewriting won't work.

In the httpd.conf file I have AllowOverride FileInfo. In the .htaccess file in top level of my webserver with all the other files, I have this: RewriteEngine On RewriteRule ^downloads/?$ index.php?page=downloads [L,NC] But it doesn't work. mywebsite/downloads and mywebsite/downloads/ always give a 404 not found. Any idea why? Thanks. ...

PHP logging solution?

i am looking for a php logging solution like log4net. do you know any solution or can you suggest anyone? ...

mySQL - One large query vs Ajax indivdual queries

Hi guys, I guess no one will have a definative answer to this but considered predictions would be appriciated. I am in the process of developing a mySQL database for a web application and my question is: Is it more efficient to make a single query that returns a single row using AJAX or To request 100 - 700 rows when the user will l...

How to implement Pagination?

What is the best way to implement simple pagination? Here is the code im using to put the items from the database into a table: $sql = "SELECT * FROM table WHERE id='id' "; $result = mysql_query($sql); while($row=mysql_fetch_array($result))} echo($row['id']); echo($row['name']); } I just wanted to pageinate this so i would u...

Round to nearest 10

How can i round to nearest 10 in php? Say i have 23, what code would i use to get it to 30? ...

Redirect user to the last page on my pagination...

I know this sounds confusing: I have just built some basic prev/next pagination for mysql and i wanted to know, if the last page of my rows is .php?page=5 and someone puts .php?page=263 then i want to redirect them to .php?page=5 Any ideas on how to do this.. the info i currently have is, how many rows are returned after the LIMIT so i...

How to batch execute php script from one php script?

I have a series of php scripts that I want to run in a particular order. I tried using: <?php exec('file1.php'); exec('file2.php'); exec('file3.php'); ?> to accomplish this, but just got a series of errors. If I run them from the command line, they all work fine... I'm not sure how to do this... if someone can help, that'd be gre...

how to format date coming from MYSQL

Hi Simple question but i need it :) $query = "SELECT * FROM `set` WHERE ID = '$id'"; $result = mysql_query($query); $info = mysql_fetch_assoc($result); $frmdate = $info['date']; So far i tried $timestamp = strtotime($info['date']); $joined_date = date("j M. Y", $timestamp); but no luck ! "date" field in mysql is DATE data ...

php encryption sql

I want a form where user can change password. I am able to encrypt a password, however when it is selected from the database(the original password say 'test') it does not recognise it. This is when the password has been encrypted in db. i am checking to see if the typed password in form matches the one in the db: SELECT * from table wh...

How to "echo" a class?

This is probably really easy but I can't seem to figure out how to print/echo a class so I can find out some details about it. I know this doesn't work, but this is what I'm trying to do: <?php echo $class; ?> What is the correct way to achieve something like this? ...

Monthly categories with MySQL DATE Type.

Hello, I'm building a mini news CMS where the news added are sorted using a DATE type column e.g. INSERT date_posted=NOW(), etc. I can then easily list out all the available months with: SELECT DATE_FORMAT(date_posted, '%M %Y') as date_posted. This makes the monthly categories list. The issue I'm having is with displaying all the news ...

How to display many nested lists using PHP?

I was wondering how can you generate lists that have many nested lists deep using PHP. How would you go about coding the PHP. I'm stumped please help I'm new to PHP. ...

Best Image type for GD?

I am using the GD Library to add text to the PNG Image of a Form, that i am using to create a pdf. My Tests show that using PNG, dosnt put to much of strain on the server just doing one, however i am concerned about scalability. So my question is does working with one file type have more overhead, than any of the others? ...

Replacing tokens in a string from an array

Let's say I have a string This $0 is $2 $1. Still, \$$3 is a lot to pay for a puppy. and an array of replacements array('puppy', 'cute', 'ridiculously', '1300') What would be the cleanest way to replace the tokens in the string with the corresponding items in the array, letting me backslash-escape the token character (in this ca...

Javascript does not load in initial page load

Hi, Im having issues with having to load my javascript, when I visit my website (php) for the first time(cookies cleared) and I click on a link (which calls a javascript method), it does not work , however if I reload the page and then click on the link, it works(the link does not refresh the page but calls another php page and makes c...

How to write a foreach that will produce the results I want

I am having a hard time getting the correct data out of an array. I wrote a nested foreach loop but the inner loop is throwing the "Invalid argument supplied for foreach()" error. Can someone please help me out with this? Thanks. foreach($row as $val) { echo $val['title'].'<br>'; echo $val['author'].'<br>'; echo $val['post']...

Possible to add javascript to Zend_Form_Element_Radio?

Ultimately, I'd like my Zend Form to render this HTML: <p>Do you have any documents to upload?</p> <p>Yes <input type="radio" value="Yes" name="uploadChoice" onClick="showTable()">&nbsp;&nbsp;No <input type="radio" value="No" name="uploadChoice" onClick="hideTable()" checked></p> Here's what I have in my Zend_Form: //create radio bu...

Javascript & jQuery escaping quotes

I'm trying to do inline editing for my website using jQuery so I can edit the HTML and text of a page without having to change the source. When I submit the form data though jQuery's $.ajax function, it escapes all the quotes. How can I either prevent jQuery from escaping this(probably a bad idea) or remove them on the PHP side of things...

how to implement conditional htmlspecialchars?

If it's <script src="/script/jquery.autocomplete.js" type="text/javascript"> ,should call htmlspecialchars. If it's <pre><code><script src="/script/jquery.autocomplete.js" type="text/javascript"></code></pre>,should leave it as is. How to do this kind of task? EDIT Think you are using wmd editor like SO,and you included some code but...

[PHP]: Error -> Too few arguments in sprintf();

This line is giving error: "Too few arguments". What is the problem? $InsertQuery = sprintf("INSERT INTO listing (ldate, places, company, designation, projectdetails, desiredcandidate, hrname, hrcontact, email) VALUES (DATE_FORMAT(%s,'%Y %m %d),%s,%s,%s,%s,%s,%s,%s,%s)", $ldate,$places,$company,$designation, htmlentities($projectdetails...