php

php for loop varable names

i got a code of 100-200 rules for making a table. but the whole time is happening the same. i got a variable $xm3, then i make a column . next row, i got $xm2 and make column. next row, i got $xm1 and make column. so my variables are going to $xm3, $xm2, $xm1, $xm0, $xp1, $xp2, $xp3. is there a way to make a forloop so i can fill $xm a...

In PHP, how can I get any string after the domain to be a php variable? Ex: me.com/FOO, me.com/VAR3

so my index.php can be this: <?php $restOfURL = ''; //idk how to get this print $restOfURL; //this should print 'FOO', 'VAR3', or any string after the domain. ?> ...

Timed planning Mysql database cleaning

We need to create a script (ajax or php or javascript) that will clean some tables from our database at fixed time. We can not use server features such like Cron tab or others. Any suggestions??? Thanks ...

php foreach as variable

I'd like to use foreach to loop though an array list and add an element to each array. $tom = array('aa','bb','cc'); $sally = array('xx','yy','zz'); $myArrays = array('tom','sally'); foreach($myArrays as $arrayName) { ${$arrayName}[] = 'newElement'; } Is the use of ${$arrayName}[] the best way to do this? Is there another op...

When loading shopping cart in Magento with a new Payment module, I get an error I haven't been able to trace.

I am trying to add a new payment module into Magento. However, even after commenting out the vast majority of the code, I still get the following error: Fatal error: Call to a member function isAvailable() on a non-object in /var/www/html/app/code/core/Mage/Payment/Helper/Data.php on line 71 I am using Magento 1.4.0.1, and have disa...

How do stop form posting to mysql if database contains a specific ID?

I have a form that I am using to post data to mysql. Before submitting the form I want to check the database and see if there are any fields in the column 'customerid' that equal 'userid' and if so not to post the form. Basically, I am trying to limit my users from posting more than once. Users will be able to login to my system and ma...

Getting the names of all files in a directory with PHP

For some reason, I keep getting a '1' for the file names with this code: if (is_dir($log_directory)) { if ($handle = opendir($log_directory)) { while($file = readdir($handle) !== FALSE) { $results_array[] = $file; } closedir($handle); } } When I echo each element in $results_arra...

PHP rewrite an included file - is this a valid script?

Hi all! I've made this question: http://stackoverflow.com/questions/2921469/php-mutual-exclusion-mutex As said there, I want several sources to send their stats once in a while, and these stats will be showed at the website's main page. My problem is that I want this to be done in an atomic manner, so no update of the stats will overla...

Triggering PHP from ActiveMQ

Background: Our current system involves two services (one written in Java, the other in PHP) that communicate with each other using HTTP callbacks. We would like to migrate from HTTP callbacks to a message-based architecture using ActiveMQ (or another, if necessary). We'll probably use STOMP to communicate between them. Eventually, the P...

Searching by key in Apache CouchDB

Is it possible to search by key value in Apache CouchDB? Given the sample data below (spaced for readability): { "_id":"a754a63dcc7f319b02f7ce6de522ca26", "_rev":"1-5bd88e53fe0869b8ce274b49a2c1ddf5", "name":"john smith", "email":"[email protected]", "username":"jsmith" } Could I query the database for the user j...

tiny mce sql error when adding links

I am using tiny mce with a script I built for uploading some content to a blog like system. Whenever I add a link via tiny mce I get this error. The field type in mysql for $content which is the one carrying the link is longblob if that helps. here is the link error first and then my code You have an error in your SQL syntax; chec...

Trigger file download on a page with content

I have seen many websites triggering a file save-as dialog on a page with existing HTML content. How do they do this? I know about setting the right headers such as Content-disposition etc. but when I do that, the content of the page does not load, and immediately the file download is triggered... ...

Should I go for Arrays or Objects in PHP in a CouchDB/Ajax app?

I find myself converting between array and object all the time in PHP application that uses couchDB and Ajax. Of course I am also converting objects to JSON and back (for sometimes couchdb but mostly Ajax), but this is not so much disturbing my workflow. At the present I have php objects that are returned by the CouchDB modules I use an...

Stopping users posting more than once

Before posting my form I am checking the database to see if there are any previous posts from the user. If there are previous posts then the script will kick back a message saying you have already posted. The problem is that what I am trying to achieve isn't working it all goes wrong after my else statement. It is also probable that the...

What kind of cool stuff can I do with PHP's streams?

It seems that PHP's streams aren't used much, but they appear to be very powerful. Does anyone have an example of implementing a stream to do something that would be clunky otherwise? I don't mean doing stuff like file_get_contents('http://google.com');, I mean implementing your own streams. ...

Get websites title and description, save to utf8 table, php/mysql

Hi guys, I've been trying today all day to figure this out and I have no idea. What I want: Get the title and meta description of any kind of website. Save this info to utf table in mysql. What the problem is? Different sites have different charsets which results in that some have chinese, some contain umlauts (german), then we have ...

[PHP] Difference between exceptions and errors?

What is the difference between an error and an exception? I have read numerous resources online and in a couple of books, but the explanations provided are not very thorough. As such, I am still confused. Thanks! Edit: It looks like I asked two questions which was probably confusing. The main question that I wanted an answer to is th...

what is the best and easiest to draw a multi bar chart in php

i want to display the results of students scores in a multi-vertical bar chart (red bar for correct , green bar for false) for each question,, i already tried Google chart, but it gives me result in this way:link text note: the bars that reached the top , should not be at top ,, only because they have the highest value (75%), Google ...

Valid Email Addresses - XSS and SQL Injection

Since there are so many valid characters for email addresses, are there any valid email addresses that can in themselves be XSS attacks or SQL injections? I couldn't find any information on this on the web. The local-part of the e-mail address may use any of these ASCII characters: Uppercase and lowercase English letters (a...

PHP, MySQL, jQuery, AJAX: json data returns correct response but frontend returns error

Hi all, I have a user registration form. I am doing server side validation on the fly via AJAX. The quick summary of my problem is that upon validating 2 fields, I get error for the second field validation. If I comment first field, then the 2nd field does not show any error. It has this weird behavior. More details below: The HTML, JS...