php

How to ensure that MySQL rows are unique?

I am trying to insert a row into a MySQL table, with the condition that the row itself has to be unique. So for example, the row would have id, name and address, but we can't have an insert with duplicate name and address. I tried doing a select before inserting, to make sure I don't find the result, but it doesn't seem to be working. I...

Understanding Classes in PHP

I'm officially mentally retarded. [Let me explain] I've never really given classes and their relationship any thought until today. I'm trying to figure out something that seems to be pretty obvious but since I'm stupid I can't see it. Let's say I have a Core Class that will be extended from different files. How can children classes cal...

php login script security

I just wanted to run my login script by you guys to see if there are other security measures that i should take. I know that i need to move my DB constants to a config file but aside from that and some error handling, what other checks to i need to add to make sure this script is secure? <?php ob_start(); session_start(); ...

Dynamic header with PHP?

I know this is a basic PHP question, and I'm trying to learn the stuff. I very familiar with HTML, CSS and familiar with the CONCEPT of PHP, but not with specifics. I have always partnered with a back end developer to accomplish this stuff and to set up wordpress sites, etc. I'm building a very basic four or five page website (a showca...

How to make currently selected drop down menu item be preselected from database?

I tried this on my own but couldn't get it to work right. Basically I am making an edit page where a previously submitted post can be edited. On this new page the form is pre-populated with previously submitted data. One of the things that was chosen earlier was a category from a drop down. I am trying to have that previously choden cate...

Upload image by using Flex and PHP..

Hello I was wondering if anyone knows the best way to upload the image file by using Flex 4 and PHP. I have searched online but most of them are using Flex 2 or older version. I am just curious if there are any new ways to do it. If you know any good sites or articles, please reply. I appreciate the help! update: just found a good ...

How do I select multiple tables in one line?? and insert into??

Hi I would like to select multiple table in one query say like below and insert into multiple table: $result = $db->sql_query("SELECT * FROM data1,data2,data3,data4 WHERE person='" .$name. "'"); $row = $db->sql_fetchrow($result); $day = $row['regtime']; $days = (strtotime(date("Y-m-d")) - strtotime($row['regtime'])) / (60 * 60 * 24); ...

Maintaining the Value in Zend_Form_Element_File

I have a single Zend_Form_Element_File element that handles the upload just fine. What I want to know is, is it possible to use the Zend_Form_Element_File element only and still maintain the value that was originally uploaded? Generally this sort of thing would be handled via a hidden field but I would like to keep it in the Zend_Form_El...

Echo current number of row

Hi! My $num_rows echos the total row count but I want the current row number. <?php $result = mysql_query('SELECT * FROM texts ORDER BY id desc'); while($row = mysql_fetch_array($result)){ $num_rows = mysql_num_rows($result); ?> <tr class="alt"> <td><?php echo $row['id']; ?></td> <td><?php echo $row['title']; ?></td> <td><a...

Apache Redirect Problem

Hi Ive a strange problem, Im getting referals from a website and the site is calling a url that is not avaliable Code: http://nzbuse.net/udnc.html/img/logo.jpg Ive tried to redirect by .htaccess, errordocument and php script but non seem to work. When my index.php page loads it includes javascript and css, the site also uses smarty. ...

Preg Replace question PHP

Im new to Preg Replace and Ive been trying to get this to work, i couldn't so StackOverflow is my last chance. I have a string with afew of these ('pm_IDHERE', 'NameHere');"> I want it to be replaced with nothing, so it would require 2 wildcards for NameHere and pm_IDHERE but ive tried it and failed myself, so could someone give me ...

What to choose for article management website

Hi Guys, I have some questions regarding article management system. I am thinking of making a website where people will become members and write their articles, they can publish them, rank them etc. And i have been googling for past two weeks that which technology is best. And how to store the article so that search engines (like googl...

How to save DIV tag to MySQL with PHP and jQuery

Hello eveybody, I'm using jQuery + PHP + MySQL My problem is how to save for example this div in my MySQL database using an Ajax call with jQuery to PHP. PS. i know how to send an Ajax call with jQuery to PHP and save variables from this call to MySQL. <div id="id-aaa"> Les ordinateurs, eux, comme on l’a vu, ont un dispositif physiqu...

Is it possible to call C code from php

Hi, is it possible to call C function from 3rd party C library from a PHP5 script. If so any link or how to do it please. Thanks ...

Trying to digitally sign via HMAC-SHA1 with PHP

Hi, I'm trying to setup some google maps premier API action, and to do so, I need to sign my URLs to authenticate. If you go down to Signature examples, there is some Python, C# and Java code to show you how to do the signature via HMAC-SHA1. There is also an example so that I can to test my PHP implementation. However, I just can't ...

Will creating new array clear the whole php session data?

Code below: $_SESSION = array(); Will it clear all session data? If I wouldn't want to use session_destory(). ...

Making my code easy to write plugins for

Hi all, I have been writing some code that creates a generic blog. Its features are simple, create a post, edit and delete the post and allow comments. I am trying to write it so that it is very easy to write plugins for, however Im not sure on the best approach. Some of my ideas: Have the plugin author write a short script call...

Routing URI requests to private methods in CodeIgniter?

Is this even possible? By using a custom route like: $route['ajax/:any'] = "ajax/route"; And then declaring the method private in the controller: class Ajax extends Controller { function _route() { some code here... } } I know this example does not work in practice, but you get the idea. ...

How can I use regex to grab the information on the END of a line?

For example, http://api.hostip.info/get_html.php?ip=12.215.42.19 When visiting that URL, it will return: Country: UNITED STATES (US) City: Sugar Grove, IL IP: 12.215.42.19 I want to set Sugar Grove, IL to a variable, after visiting that URL. How would I make it find the City, and then set it to a variable? ...

PHP Code to generate event to repeat in a random shuffle of intervals between 1-20 seconds.

This program sends an email every 20 sec. How can I amend the code to have it send an email, then pause for a random number of seconds between 1 and 20, then repeat till the end ? Any help on this is much appreciate. Thanks in advance! Here is the code that is associated with the Delay section of the User Interface as it is if (!$d...