php

How to include a class

I have index.php and I want to include class.twitter.php inside it, how do I do this? Hopefully then when I put the below code in index.php it will work. $t = new twitter(); $t->username = 'user'; $t->password = 'password'; $data = $t->publicTimeline(); ...

PHP class and method

Im using class.twitter.php (http://emmense.com/php-twitter/documentation/v11-methods-available/) Im using this code: $summize = new summize; $search = $summize->search('#test'); echo "<pre>"; print_r($search); echo "</pre>"; And the output is: stdClass Object ( [results] => Array ( [0] => stdClass Object ...

stop null values passing to mysql

i want that when i pass query that add values in mysql database then null values should not be passes what should i do ? and where and how to use these codes ? please tell me in detail i am totally new here ...

print passes values

i am using insert into db(fname,lname) values ('$fname','$lname') command i want that when this query passes on the nest page it show me which fname and which lname is passed or added like this statement Following recorded is updated in database successfully first name = abc last name = xyz ...

print passes values to Mysql

i am using this code to add values to database <?php $debdes = $_POST['debdes']; $debamt = $_POST['debamt']; $crdes = $_POST['crdes']; $cramt = $_POST['cramt']; $date = $_POST['date']; include_once ("db.php"); $ucbook = "INSERT INTO cbook(debdes,debamt,crdes,cramt,date) VALUES ('$debdes','$debamt','$crdes','$cramt','$date');"; ...

Salting Algorithm Strength

What are the advantages / disadvantages of those 3 methods to create a salt? $salt = md5($password); $salt = sha1(md5($password)); $salt = generate_random_number(); Computing hash: $hash = sha1($salt + $password); ...

delete user best practice?

ive got a forum and i allow user to delete their account. and i want the users threads to still be there and the username to be shown, but i wonder one thing. if a user is deleted (basically i just NULL their username and password in the table row but i leave everything else intact) and another user is registering the same username, th...

Managing animated images in PHP

Hello! I would like to have some information about this topic. Everybody knows that it's possible to manage and even create images with PHPs gd-library, but is it possible to edit animated GIFs without losing the animation? Hope that someone is wise enough to answer this :) Martti Laine ...

Simple foreach loop

I have this code: $summize = new summize; $search = $summize->search('#test'); $text = $search->results[0]->text; $text stores the result, but only the first result of the array. How ca a write a loop to go through all the values and output through say echo... ...

php stop passing null values tp mysql

i am using following code to add values $debdes = $_POST['debdes']; $debamt = $_POST['debamt']; $crdes = $_POST['crdes']; $cramt = $_POST['cramt']; $date = $_POST['date']; include_once ("db.php"); $ucbook = "INSERT INTO cbook(debdes,debamt,crdes,cramt,date) VALUES ('$debdes','$debamt','$crdes','$cramt','$date');"; now i want that...

What is the best OOP approach to implement the best Category and Products relationship using PHP?

I am trying to design a PHP project's structure. What I am not very sure about is how to implement categories and products relationship. A category has one parent, and can have many children. Product belongs to only one category. Db tables are like this: products: id product_name category_id categories id category_name parent_id ...

How to fix this problem in PHP?

$onethird = 1.0/3; $fivethirds = 1.0/3+1.0/3+1.0/3+1.0/3+1.0/3; $half = 1.0/2; $threehalf = 1.0/2+1.0/2+1.0/2; var_dump($onethird + $fivethirds == $half + $threehalf); which outputs false,but as we all know:5/3+1/3=2=3/2+1/2 How to fix this problem? ...

netbeans 6.7.1 autocomplete question

Hello, I am using Netbeans 6.7.1 to code in PHP. I have a problem with autocomplete. If I write strrev get no autocomplete for it if I press CTRL+space and then I type str I get a list of function names including strrev. My question is: Is there no way to make this automatic like in Visual Studio or Zend Studio and not have to press C...

get last record of a table

I have a form that lets users create new records, In the field that is the id that auto-increments i want the user to see the record number that this record is by somehow showing latest value+1 in the fields value. I was thinking of something like: <input type="text" value="<?php echo $myQuery['recordId'].length+1"/> But that doe...

php time difference script problem

here is my php code..... <?php function nicetime($date) { if(empty($date)) { return "No date provided"; } $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade"); $lengths = array("60","60","24","7","4.35","12","10"); $now = time(); $unix_date ...

looking for transpiler: php to javascript

hello, i wonder, if there's any transpiler available, which converts (simple) php code to javascript? what i am not looking for is ajax stuff or javascript libraries imitating php functionality, but i am looking for a translater, which is able to generate javascript code from php code (similar of what google is doing with GWT and the j...

Open text file read comma seperated values

I have the following code: $pollids = "pollids.txt"; $contents = file_get_contents($pollids); list($pollid) = explode(',', $contents); echo $pollid; This opens a text file containing a comma seperated list of text: value1,value2,value3 etc... However it only echo's the first piece of text in the file. How can I get it to lopp/fetch ...

playing a sound on content update with php ajax

how can i play a sound if the content of a div is updated via ajax or $.ajax() and it not plays any sound if no content is updated.... i am using jquery with php and loading posts from database and want to play a sound if new posts found every 3-5 mintues...via $.ajax() ...

NOW() function in PHP

Hello, Is there any PHP function that returns time format as the MySQL fuction NOW() I know how to do it using date() .. but I am asking if there is a function only for this. e.g. "2009-12-01 00:00:00" ...

switching between divs with jquery

suppose i have a list of users.... <a href="#">user1</a> <a href="#">user2</a> <a href="#">user3</a> i want to switch div content related to the user while click on it and also want to align that div to the bottom right corner....i.e. user1 user2 user3 how i should do that with jquery and $.ajax() ...