php

How can I store a date in a MySQL database using PHP?

I want to store a date value in a MySQL database. I have one PHP page called A.php that has 3 inputs: d, m, y, where d = (1 ... 31), m =(1 ... 12) and y = (1970 to 2009). Now in b.php I collect this values and I need to store in my db. My DB has a field called dob which is of date type. How can I construct a variable of type date fro...

How to re-index the values of an array in PHP?

Array ( [id] => 3 [user_id] => 1 [clan_id] => 1 [date] => 2009-09-24 09:02:05 [skill1rank] => 1 [skill1lvl] => 2376 [skill1xp] => 1804229942 [skill2rank] => 53 [skill2lvl] => 99 [skill2xp] => 120510105 [skill3rank] => 5526 [skill3lvl] => 99 [skill3xp] => 21581237 [skill4rank] => 622...

Different events when onclick tabs

Hi Guys I have created a tabs by jquery and i want to display different data from database at each tab how can i do that knowing that it is the same container and same data but with different conditions hope to find an answer soon And i am using php and javascript Thanks ...

How to get the biggest differences between two fields comparing all users?

I have a table that has the columns skill1xp, skill1lvl, and skill1rank for 25 skills. Each day I update it for all users, so there's a datetime column. I'm making a high-scores progress tracker for a game, for many users, and I've got just one feature left, which is Highest Gains for a certain period of time (day/week/month). I guess t...

php security: Using MD5, SHA1, Salting

Currently Many of my passwords are stored with a mixture of md5's and sha1's however I've just been introduced to salting, and wanted to know the breakdown of what might be the most secure. I'm certin that a simple md5() can easily be revoked, however what about md5(sha1(md5($var))); Does this combo provide more difficulty, or is more n...

php:uploading a file on server

I am using the following code to upload the file on my server. How do I store it in a particular folder? if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " ...

How to structure a bigger/complicated project?

Hello, I'm creating this (big?) project in high school where I'm programming the game Shithead (card game) (so that two people can play against eachother). I'll use mostly PHP, MySQL, JavaScript and Ajax. But I have never made a project like this before. I have only made like CMS-systems and so on. Do you guys have any tips on how I sh...

Ids from mysql massive insert from simultaneous sources

I've got an application in php & mysql where the users writes and reads from a particular table. One of the write modes is in a batch, doing only one query with the multiple values. The table has an ID which auto-increments. The idea is that for each row in the table that is inserted, a copy is inserted in a separate table, as a history ...

PHP Image Upload trouble

Hi, I am currently working on a Joomla! website. I am using the Jumi extension (which allows custom scripts to be made and executed within Joomla! itself) to create a simple file upload tool. The problem is that I get the following error: Warning: copy(C:/xampp/htdocs/images/1253889508.jpg) [function.copy]: failed to open stream: No s...

Count Number of PHP Warnings/Notices

Hello all, Is there a way I can count the number of errors/notices/warnings that a script has come across whilst executing? I wish to do something like this: Warnings: 125 Notices: 234 ..etc Thanks ...

MYSQL: SQL query to get the value of autoincrement field

I have a table. The primary key is id and its auto incremented. Now when I insert a new record, I need to get the id with which the record was updated. How can I do that? If i use the query... select max(id) from table_name ...after executing I can get the id. But can I be sure that its the id of the record that was just inserted? ...

Compare database value to number of rows in another table

Hello all. For each item in the first table, there is a 'numberOf' field. The value of this field must have an identical number of rows in a related table. These are like reservation rows so multiple users can book the item at the same time. This syncronisation sometimes goes out and there are more rows than the 'numberOf' field variabl...

What are some things to keep in mind when building e-commerce sites?

hello all, In the coming months, I will be tasked with creating an e-commerce site for the first time. I've worked with e-commerce sites before, making edits and themes but never made one from the bottom up. I know this isn't a small undertaking which is why i'm doing research now! What are somethings that i would only learn from exp...

PHP Simple way to obtain value from multi level object

I know I can loop through each level of the object, but I would like a more simple approach to this. QueryResult Object ( [queryLocator] => [done] => 1 [records] => Array ( [0] => SObject Object ( [type] => type_1 [fields] => [s...

User Login with a single query and per-user password salt

I've decided to implement a user login using a per-user salt, stored in the database. The salt is prefixed to a password which is hashed with SHA and stored in the databse. In the past when I wasn't using a salt I would use the typical method of counting the number of rows returned by a query using the user inputted username and passwo...

Installing PDO_MYSQL PHP extension on CPanel?

I recieved this error while installing Magento on a customer's server, 'PHP Extension "pdo_mysql" must be loaded'. How would one go about installing/enabling this extension through CPanel Accelerated? Server information is as follows: cPanel Version 11.24.5-STABLE cPanel Build 38506 Apache version 2.2.13 (Unix) PHP version 5.2.8 MySQL...

register_printf_function in PHP

I need to let the user specify a custom format for a function which uses vsprintf, and since PHP doesn't have glibc' register_printf_function(), I'll have to do it with PCRE. My question is, what would be the best REGEXP to match % followed by any character and not having % before it, in an usable manner for programmatic use afterwards?...

Coding standards and design patterns in PHPSpec library

I really like the codebase of PHPSpec. Could any of you guys mention any standards and/or design patterns that are prominent in this library as that is how I want my code to be? ...

Parsing PHP array which has an abject inside

I've got a response form the solr query in php. below is the response form apache solr in drupal6, i need to access the id field inside the Apache_Solr_Document, can some bosy help me with this. i was able to print this using print_r($result); Array ( [type] => Bookmarks [node] => Apache_Solr_Document Object ( [_documentBoost:protect...

multiple select in one statement

This is hard to explain but i need to - select id from customers - foreach customer find the order with that id -- foreach order (for that customer) --- select product.name, product.max on order.productId=product.id I dont know how to pull this data. I would need multiple separate selects? can i write a long single sql statement (';' ...