php

php while loop variable for every third div

Is their a way in a while loop to assign a variable to a class in a div, for every third item in a while loop. I am using the blueprint structure and the third div is at the end and i need to attacht a "last" class name to every third div so 3rd div 6th div 9th div and so on? /* LOOP THROUGH SHOEDATA TABLE */ $results = mysql_query("SE...

html to php data manipulation

Given this code snippet, I know that if the user selects 25c the value 25 will be sent to the php script; however, I am having issues trying to figure out how to setup the data on the php script so that I could manipulate it. <label><b>Quarters:</b></label> <select name="quarters" > <option value="25">25c</option> <opti...

Is it possible to send a http request only to get the last modified time?

Instead of the file itself? EDIT Best with a demo in PHP? ...

Is there a less hacky way to do this in MySQL?

I need to get the last inserted product by a user. This is what I've came up with $query = 'SELECT id FROM products WHERE user_id = ? ORDER BY id DESC LIMIT 1'; It should work because the id is auto increment. To me though, it feels hacky. Is there a better wa...

What type of caching should I use ?

I have a classifieds website, which uses PHP and MYSQL. I have several pages which uses javascript also. I need to know what type of caching to use to increase performance on my site... There is alot of 'constant' images like menues, sidebars, background-images which probably can be cached in a way. Do you know if web-browsers cache t...

When is best to use exceptions in PHP?

I usually indicate an error in a method by returning false, but it doesn't always gel with me semantically (as depending on the method, false may be a valid return). I've looked into exceptions, and am wondering are they a one-size-fits-all solution? Should I return false where I can still? I may be completely missing the point here so...

How to display static text and dynamic text(generated by variables) differently in PHP?

A HTML file is generated by a PHP file. Generally speaking, what a user can see from a HTML file can be divided into two parts, one part is static; another part is dynamic, this part is represented by variables in the PHP file. For example: $html=<<<eod $title<br/> Total Price:$row[column1] Quota:$row[column2] <pre>$row[column3]</pre>...

How to display name in the from address?

Hi, I have a site in PHP.In this when I send the invitation to people it takes the from address as [email protected] of this I want o display the Mysitename .How can I do.I have the code shown below. $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "...

code for finding the state,country,city from the IP Adress in php

Sir, I developing a site. In which i get the IP addresses of the users from where they are entered. Now i want to find the State,City and country from where they are entering.That means i want to find the state, country, city from the IP address of the user. the code i need in php. can you help me to do that ...

Convert multi-dimensional multi-object array to standard multi-dimensional array in PHP

I have a multi-dimensional multi-object array from a simplexml_import_dom() function call. A slice of one section of the array: [Price] => SimpleXMLElement Object ( [Prices] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( ...

Adding my custom PHP Library in include_path

I want to add my PHP library file to be included in include_path, so that i can access it from anywhere in my application running on that server. I tried adding it as per the syntax for include_path in php.ini But its not working. I tried get_ini("include_path"); and got the value perfectly. But my functions are not inlcuded in my applic...

Is it ever justified to write a fairly large, database-centric PHP app procedurally and without MVC?

Sorry for the rather subjective question, but I was hoping to get an opinion from someone more experienced than myself on this. I'm pretty far into an ajax-driven PHP application and, while I have pretty good separation between markup and behavior on the client side, my PHP is slowly becoming a bit of a mess. I'm doing alright so far b...

php handling money and money values

Are there any standards or rules to follow when handling money and denominations in php like .45c, .35c or $4.00 as values? I don't want to do this 400 cents as a value for $4.00, I just wanted to use $4.00 dollars as is in php without modifications, likewise .50c as is. ...

If [Get Variable] is equal to [Array]

I am trying to find easier and simple way to code a logic. That is if one variable is equal to any key values in an array. For instance: $someArray = array("a","b","c"); If($_GET["foobar"] == $someArray) { return true; } else { return false; } If the $_GET["foobar"] had a value of A, B, or C, the case would return true. If...

alternative to mysql_fetch_array()

I want to execute a query and either it will return one row or none. I don't want to use mysql_fetch_array(). What else can I do? ...

Apache httpd error and crash

I have a WAMP 2.0 server installed on Win XP . Apache version : 2.2.11 PHP Version : 5.3 MySQL : 5.1.36 I have about 11 tables in the mysql . Each run of my web application (HTML/Jquery/PHP/MySQL) fills about 100 rows in 2 of the tables.(One of the table has 2 Long blob columns where data of size upto 20MB is uploaded, I have changed...

Fatal error: Call to a member function prepare() on a non-object

Hi, We have a Document Management application. I have 5000 image files loaded in mysql DB. Need to delete them when the folder is deleted at the client. Using the following code, public function delete($dbh){ $sql = "DELETE FROM fileTable WHERE FID=:fid; DELETE FROM file_blobTable WHERE FID=:fid"; $stmt = $dbh -> p...

Php Login Issue (Users cannot login and users can use others passwords to access their own accounts)

Ok so here is my issue, Some users cannot login to their accounts. They enter in their password and username properly but it just doesn't seem to work. and secondly I noticed that a few of the users can log into any account they want with their own password and not the password of the original account. using MYSQL, and PHP5. /*Login ...

asp.net mvc vs php mvc vs just php for cafepress type site

Hi guys, I dont have experience in web programming. I so far I coded in c++ only. If I wanted to build a site similar in functionality to cafepress.com which route would be most suitable for me? asp.net mvc or php mvc or just php? Granted I am new at this, still the amount of options is overwhelming to a newbie. And there is no decent g...

Parse error: syntax error, unexpected $end in E:\xampp\htdocs\announcements\announcement.php on line 143

I get this error message Parse error: syntax error, unexpected $end in E:\xampp\htdocs\announcements\announcement.php on line 143 Line 143 is the last line of the PHP file. When I comment out $htmlcode=<<<eod <div>$question</div> <div>$option1 $option2 $option3 $option4</div><br/> eod; echo $htmlcode; The error is...