php

PHP Constants Containing Arrays?

This failed: define('DEFAULT_ROLES', array('guy', 'development team')); Apparently, constants can't hold arrays. What is the best way to get around this? define('DEFAULT_ROLES', 'guy|development team'); //... $default = split(DEFAULT_ROLES, '|'); This seems like unnecessary effort. ...

Having problem with foreach: Giving me warning

Hello all, I have this: foreach ($country as $value){ The contents of $country using print_r is this: Array However, when I print_r all of POST variables it shows me country as single array rather than an array within an array as the above suggests? Array ( [entry] => http://www.google.com [SelectLocation] => Canada ...

PHP + MySQL problems :(

Hello, I am havin trouble with this code: if ($_GET['offline']) {$extranet = $_GET['offline'];} else {$extranet = $online;} $sql = mysqli_query($db,"UPDATE tbl_system SET value = '$extranet' WHERE property = 'extranet'"); echo $_GET['offline']; echo $extranet; echo $online; In the database, the value of the field where the property =...

Refilling a select box with POST data (php)

Hi all, I have a select box that shows 3 options: option1, option2, option3. When a user hits submit, then in $_POST I do have the value selected. Is there an easy way to redisplay the select box with the chosen option highlighted WITHOUT it being repeated in the options? In other words, if option2 is selected and submit is clicked...

How to avoid Page Reload Resend-Data message with PHP

I am relatively new to PHP, so my apologies if the answer is trivial. Lol I wrote a simple Contact Us email form (actually a WordPress page-template file). All the code is in one file. After the user submits the form and the email is sent, the file generates a Thank You message. If the user reloads the Thank You page, they are prompte...

Can not output image into src tags

Hello all, I have the following: $imageurl = "<img class='item_thumb' src='getimagethumbnail.php?imagename=".urlencode($product_image)."&from=".$prodimagedir."' min-width='150' min-height='150' border='0' class='item_thumb'>"; Which creates the following html: <img class="item_thumb" border="0" min-height="150" min-width="150" src=...

Count number of MySQL queries executed on page

Hello, how would I count the number of sql queries executed on one page load? I have a similar script to time taken for page to be generated, but not for how many queries have been executed. You know what I mean, such as on SMF forums, in the footer, they have: Page created in 0.136 seconds with 7 queries. in the footer? Replacing a...

How to create a secure mysql prepared statement in php?

I am new to using prepared statements in mysql with php. I need some help creating a prepared statement to retrieve columns. I need to get information from different columns. Currently for a test file, I use the completely unsecure SQL statement: $qry = "SELECT * FROM mytable where userid='{$_GET['userid']}' AND category='{$_GET['cate...

Algorithm to look up the date range based on event date

I'm writing a PHP function that would use a table of sorts to look up which DB shard the application should go to, based on the datestamp I have. The shard configuration is something like this (pseudo-code): the first column is the date of the event I'm looking for and the 2nd is the shard the event resides in. pre-2008 -> shard1 2008-...

Drupal 6: Programmatically Altering User Values (how do you use profile_save_profile??)

I've been trying to figure this out for quite some time without success. foreach ($users as $user) { //list of users to act on $by_user = views_get_view_result('attendance', 'page_3', array($user->uid)); //view containing info about this user $edit = array('profile_attendance_short_term' => substr(count($by_user) / count($general), 0,...

MySQL Slow on join. Any way to speed up

I have 2 tables. 1 is music and 2 is listenTrack. listenTrack tracks the unique plays of each song. I am trying to get results for popular songs of the month. I'm getting my results but they are just taking too long. Below is my tables and query 430,000 rows CREATE TABLE `listentrack` ( `id` int(11) NOT NULL AUTO_INCREMENT, `se...

passing a null value to mysql database

A user fills out a form and if they choose to not fill out a field that is not required php does this: if($_SESSION['numofchildren']=="") $_SESSION['numofchildren']=null; But when I use the session variable in a mysql query, the result is not null, but is 0. The column is a tinyint(4) that allows NULL. Why am I getting...

setcookie("user", "", time()-3600) not working

I tried to use setcookie("user", "", time()-3600) to delete a cookie from php, but it's not working for me, when I check in the tool of the broswer, the cookie seems to still exist. Does anyone know why? note: this is the domain cookies.. mean I set this cookies with this way setcookie('user','true',time() + 2592000,"/",".user.com",0);...

Dynamically-naming databases with PHP/SQL

Hey there guys and gals. I'm very new to php and am following various tutorials, reading books, watching videos etc. The reason I'm learning is to create one specific web application, as well as to make that jump from simple geek to proper nerd, of course. So far I've managed to learn most of what I need to create this web app. The key ...

How do i retrieve all recently updated events in Google Calendar?

Hi Everyone, I am currently working on a Google Calendar Sync Feature which is supposed to sync with our own Calendar app and to the Google Calendar app. Now I need to identify the recent changes in Google Calendar so I can copy these events into our Calendar App. I use the zend gdata however any idea I would appreciate. ...

How can I get a list of methods that are originally *defined* in a class in php?

I'm trying to get a list of methods that were actually defined in a definition for a given class (not just inherited from another class). For example: class A { function bob() { } } class B extends A { function rainbrew() { } } class C extends B { function bob() { } } echo print_r(get_defined_class_methods("A"), true)."<br>\n"; ...

Template Monster API - ID Based Information (PHP)

Good Evening, I'm currently working with the Template Monster API and I've ran into a quick question. I've managed to get all of the categories to list their available templates and then assign the links to step1.php?templateid=11331. Once the user arrives on step1.php, I'm able to get the ID number from the URL and pass it to the Te...

Data preload & memory management in PHP

Hello, I need to do a big database preload in a PHP webpage (which requires an ini_set of 1024MB) for a database export in CSV format (data preloaded in an array). I know this is not always the right choice but the fact is that I need to do it, so here's the main technical question : How can I be sure that all the preloaded data is cl...

Need ASP.NET CMS like MODx PHP one

When I need to develop a solution using a CMS I recommend to my clients to use MODx, flexible to me as developer and easy to user for content managers. This time my client has introduce a requirement: the solution should be using ASP.NET. The problem is that in my research I couldn't find an equivalent ASP.NET CMS to MODx (http://modxcm...

Cron on XAMPP (windows)

I am developing a site locally using xampp. I would like to configure cron, so the dev environment is the same as the production environment. However, my system is windows vista. Is there any way to do this, or am I forced to accept that my dev and production environments will be forks? ...