php

How can I select like this using mysql query?

Hi I have two different tables containing lot of images. I need to display 50 random images from both tables. How can I do like that. How can I select random images using MySQL? or if I select 100 images from both tables. How can I choose 50 random images from that array using php? any body knows the solution please help me. ...

How can I optimize my xml output so that the data transfer time be lower?

HI, I have a cron that calls a basic API URL. The output is xml so I use php's file_get_contents() to get the data to process. My question is, Does the output format of the xml make a difference in the transfer time from one server to another? The cron is running every ten minutes and I don't want the crons to overlap at some point bec...

Issues in hook_form_submit() in IE browser

i have a custom module with a form I have implemented form hooks like this hook_form() hook_form_submit($form, &$form_state) When i have a print statement in _submit it doesnt show on the screen , but which works fine in mozilla firefox . In IE _submit is only not getting called , am using drupal_render to render each form elements in...

Get_File_contents and MINE TYPE ...

<?php $file = file_get_contents('http://domain.com/background.gif'); echo $file; ?> it echo a very long string(GIF89aÅÕ2cŒ®³¾J}BvUyš±µÁJr•O€d,,,,), not a image, how to fix it? ...

Replace PHP's realpath()

Apparently, realpath is very buggy. In PHP 5.3.1, it causes random crashes. In 5.3.0 and less, realpath randomly fails and returns false (for the same string of course), plus it always fails on realpath-ing the same string twice/more (and of course, it works the first time). Also, it is so buggy in earlier PHP versions, that it is compl...

php exceptions extra parameters

Is it possible to add an extra parameter when trowing an exception? When i trow an exception I send along the error message but i would also like to send along the name of the field in a extra parameter. Something like throw new Exception('this is an error message', 'the field'); So when i display the message i can do something like ...

How to find first/second element of associative array when keys are unknown?

In PHP when you have an associative array, e.g.: $groups['paragraph'] = 3 $groups['line'] = 3 what is the syntax to access the first or second element of the array when you don't know the value of the keys? Is there something like in a C# LINQ statement where you can say: $mostFrequentGroup = $groups->first()? or $mostFrequentGro...

Store data in MySQL

I have a form to fill which has several input fileds and 20 checkbox My question is how to organize the records of the selected checkbox in mysql and what is the best way to search for them with php. Can you give me an example? ...

Convert serialized string from PHP to array in AS3.0

Hi there I'm busy communicating with my Flash file with a PHP script which in turns communicates with my db, I need to pass an array from PHP back to Flash, which happens correctly I assume, but I'm unable to unserialize the string correctly when it returns, my string looks like this: memberNum=2&success=1&teamMemberID%5B0%5D=1&teamMem...

hierarchy loop mysql php

i want to display all users which are below my status. the lead_id shows my id if i'm the manager. all users when registering will have to put the person in charge id(lead-id) but in my case, i'm getting only users with my id. e.g id name leadid 1 xxx 0 2 aa 1 3 sdd ...

PHP encoding to only have letters and numbers

Is there a encoding function in PHP which will encode strings and the resulting output will only contain letters and numbers? I would use base64 but that still has some stuff which is not numeric/alphanumeric ...

Reference service-side code from <script> tag

I don't know where I got the idea before but a year ago I wrote this in php: <script type="text/javascript" src="http://www.mydomain.com/getmarkers.php"&gt;&lt;/script&gt; Now I'm ready to convert this website to an ASP.NET MVC website and I'm wondering what the best way is to convert this into something more 'normal?'. The options ...

php - not able te receive the email

Below is the code <?php ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); include('config.php'); // table name $tbl_name="temp_members_db"; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $email=$_POST['email']; $country=$_POST['country']; // Insert data int...

Want to pass php variable as argument in javascript function?

Hi friends, i want to pass my php variable in one javascript function. i know it seems simple but i don't know where am i missing something? <?php while($gg=mysql_fetch_array($lg)) { ?> <td id="add_td"> <?php $id = $gg['p_id']; echo "<a onclick=cnf('Are you sure you want to delete ...

Problem with extending a Class

I'm having a problem extending a class which itself further extends a abstract class. The base abstract class has the following methods: Abstract: private final __construct() abstract protected function loadFromId() private static final load($id) Class 1 extends Abstract: protected loadFromId() Class 2 extends Class 1: //nothing...

how can i 'flush' my cURL session's memory without opening a new session?

I am writing a scraper in PHP using cURL but am experiencing some memory issues. These memory issues arise since i am using a single cURL session to log in to a website, and then to scrape many pages. Is there a way to 'flush' the cURL session's memory without having to close the session, open another one and re-log in? Perhaps I coul...

How to list files and folder in a dir (PHP)

Hi I am trying to show all files and folders in a dir with php e.g Dir: system/infomation/ Folder - User Files From User - User1.txt Files From User - User2.txt Files From User - User3.txt Files From User - User4.txt Folder - Players Files From Players - Player1.txt Files From Players - Player2.txt Files From Players - Player...

$.post returning (empty string)

Hi guys, I am trying to populate a table using jQuery $.post, but I keep getting (an empty string) when I log the data using firebugs console.log(), here is the code, jQuery: $.each(data, function(i, json){ //get the system names $.post('get_system_name.php', {product_id:json.product_id}, function(data...

Swiftmailer subject and weird whitespace problem

Hey When sending a message with swiftmailer or SmtpMailer, the subject has a weird whitespace. The subject should look like this: "Newsletter October 2010 - Hello everyone" But looks like this: "Newsletter October 2010 - Hello everyo ne" The whitespace always comes up the same place. PHPmailer does not have the whitespace, but we ...

Drupal web forms that can be half-filled and remember my input when I come back

Drupal's webform module is awesome for building forms, but since my form is very long, I'd like my users to be able to: Fill in some data, Save them (without submitting the form) Do something else and finally Come back after some time to fill in the rest of the data and submit. Is there a way to do this? I suppose this is a common ...