Search found 21 matches

by FishBird
Thu Apr 12, 2012 11:45 am
Forum: PHP Scripts
Topic: Limit user to clicking only one link on a page
Replies: 2
Views: 1245

Re: Limit user to clicking only one link on a page

Allright, here is a very simple solution. Only lasts while the session is active (usually untill the user closes the browser): <?php session_start() $viewed = isset( $_SESSION['viewed'] ) ? true : false; if( $viewed ===true ){ ?> You have already watched today <?php exit; } $_SESSION['viewed'] = tru...
by FishBird
Thu Apr 12, 2012 11:40 am
Forum: PHP Installation
Topic: Have 5.2.1 in stalled, need 5.3 as well
Replies: 0
Views: 1127

Re: Have 5.2.1 in stalled, need 5.3 as well

You can simply compile php in another prefix like this: ./configure --prefix=/var/lib/phpVersions/php-5.2.17 --with-config-file-path=/var/lib/phpVersions/php-5.2.17/etc/ --with-config-file-scan-dir=/var/lib/phpVersions/php-5.2.17/php.d [ your other options ] and configure apache, nginx or so to use ...
by FishBird
Thu Apr 12, 2012 11:31 am
Forum: PHP coding => General
Topic: Please help me...... stuck somewhere
Replies: 3
Views: 1271

Re: Please help me...... stuck somewhere

Dont ever do this: $idbhnmentah = $_POST['idbhnmentah']; $productname = $_POST['productname']; $quantity = $_POST['quantity']; $price = $_POST['price']; $query = "INSERT INTO tempbhnmentah values ('$idbhnmentah','$productname','$quantity','$price')"; $idbhnmentah = mysql_real_escape_string($_POST['i...
by FishBird
Thu Apr 12, 2012 11:23 am
Forum: PHP Scripts
Topic: Separated image folder for different user
Replies: 1
Views: 872

Re: Separated image folder for different user

$foldername = $this->userid;
@mkdir( $uploadfolder."/".$foldername);
$uloadfolder = $uploadfolder."/".$foldername;

But then in your own code. Just RTF PHP M.
by FishBird
Thu Apr 12, 2012 11:20 am
Forum: PHP Scripts
Topic: Print record in the magnectic label of a credt card
Replies: 0
Views: 657

Re: Print record in the magnectic label of a credt card

The first thing to do is get a creditcard "writer" and read the manual, they usually have some kind of api you can program against, but I don't think PHP will be the solution...
by FishBird
Thu Apr 12, 2012 11:16 am
Forum: PHP Scripts
Topic: Limit user to clicking only one link on a page
Replies: 2
Views: 1245

Re: Limit user to clicking only one link on a page

Why whould you want users to only be able to see only one youtube video? I dont see any php code in your scripts, so what do you have?... sessions wont work for a whole day, and you can easily delete your cookies and the limitation is gone. You should store the ipaddress of the user in a sql table, ...
by FishBird
Thu Apr 12, 2012 10:53 am
Forum: PHP Scripts
Topic: Cron job in php
Replies: 0
Views: 1010

Re: Cron job in php

You needto set a cronjob on the server itself. You cannot start a script just by itself. To get it working without using real cronjobs, you can store in your databse when your cron last runned, and let a user activate it: $last_runned = $db->query("SELECT `last_run` FROM `lastrunned` LIMIT 1"); $las...
by FishBird
Thu Apr 12, 2012 10:23 am
Forum: PHP Scripts
Topic: Limit user to clicking only one link on a page
Replies: 2
Views: 1245

Re: Limit user to clicking only one link on a page

A very simple solution will be a session check:

video1 5 minutes:

$_SESSION['wait'] = strtotime("+ 5 minutes");

check on video2:

if( @$_SESSION['wait'] > time() ) exit("You must wait ".($_SESSION['wait'] - time())." seconds");
by FishBird
Thu Apr 12, 2012 10:08 am
Forum: PHP Scripts
Topic: Last replied date and time not same
Replies: 1
Views: 802

Re: Last replied date and time not same

You should also update the forum-board itself. But first thing is some proper sql-injection prevention: $subject=strip_tags($subject); $name=strip_tags($name); $yourpost=strip_tags($yourpost); is not enough, $subject=mysql_real_escape_string( strip_tags($subject)); $name=mysql_real_escape_string(str...
by FishBird
Thu Apr 12, 2012 10:00 am
Forum: PHP Scripts
Topic: Script not working - video file not uplodoading
Replies: 0
Views: 836

Re: Script not working - video file not uplodoading

What is the max_post_size in your php.ini?
by FishBird
Thu Apr 12, 2012 9:57 am
Forum: PHP General
Topic: Upload files and special characters problem
Replies: 2
Views: 412

Re: Upload files and special characters problem

You can write a simple function to rename the users file first before you put it on your server:

$userfile_name = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $userfile_name);
by FishBird
Thu Apr 12, 2012 9:47 am
Forum: PHP General
Topic: Need help with textboxes and code.
Replies: 1
Views: 454

Re: Need help with textboxes and code.

You cannot do this with PHP alone. Use javascript. <script type="text/javascript"> text1 = document.getElementById('text1').value * 1; document.getElementById('text2').value = (text1 * 2); document.getElementById('text3').value = (text1 * 4); document.getElementById('text4').value = (text1 * 8); doc...
by FishBird
Thu Apr 12, 2012 9:42 am
Forum: PHP General
Topic: how to hide id in url
Replies: 1
Views: 485

Re: how to hide id in url

use a rewite method.
.htaccess for apache for example
by FishBird
Thu Apr 12, 2012 9:40 am
Forum: PHP General
Topic: Posting to a new page...
Replies: 1
Views: 488

Re: Posting to a new page...

what about: header("Location: yoursite");

and at least change this:
$number1=$_POST['number1'];
$number2=$_POST['number2'];

to this:
$number1=(int)@$_POST['number1'];
$number2=(int)@$_POST['number2'];
by FishBird
Thu Apr 12, 2012 9:36 am
Forum: PHP General
Topic: Site is very slow
Replies: 2
Views: 621

Re: Site is very slow

So, and how could we know what is happening without any source of information? Most of the time you should check for slow mysql queries, see if your mysql tables are properly indexed, and check if you are using external things or if you use live image processing. That are the most common issues of a...
by FishBird
Thu Apr 12, 2012 9:19 am
Forum: PHP Scripts
Topic: Help with Pagination
Replies: 0
Views: 890

Re: Help with Pagination

Allright, a very dirty solution is this: $page = (int) $_GET['page']; $stopBy = $page*5; $startBy = $stopBy - 5; $startBy<0? $startBy = 0:""; $i = 0; $query = "SELECT model, colour, registration, price, mot, make, origcountry FROM joinedresults LIMIT ".$startBy.",5 "; $result = mysqli_query ($connec...
by FishBird
Thu Apr 12, 2012 9:09 am
Forum: PHP General
Topic: Need help with understanding these errors
Replies: 1
Views: 477

Re: Need help with understanding these errors

You use ereg_replace, thats an old function. Use preg_replace instead.

You also try to sent an e-mail, but you first need to setup a SMTP server in your PHP config first.
by FishBird
Thu Apr 12, 2012 9:06 am
Forum: PHP General
Topic: Need help with understanding these errors
Replies: 1
Views: 558

Re: Need help with understanding these errors

Well, you use an old function, ereg_replace. Replace it with preg_replace.

You also try to sent an email, but you did not setup your smtp server right.
by FishBird
Thu Apr 12, 2012 9:04 am
Forum: PHP General
Topic: "More Details" scripts
Replies: 0
Views: 412

Re: "More Details" scripts

Very simple solution is to use javascript:

Your text, blablabla
<div id="more" style="display:none">
more text
</div>

<a href="#more" onclick="document.getElementById('more').style.display=''">More info</a>


Or use jquery and ajax to load it with ajax.
by FishBird
Thu Apr 12, 2012 9:02 am
Forum: PHP General
Topic: Link Architecture
Replies: 1
Views: 450

Re: Link Architecture

A MVC architecture is always best. Take a look a the zend framework, and try to figure out what they are doing with the code flow, and use it for your own code.
by FishBird
Thu Apr 12, 2012 8:59 am
Forum: PHP General
Topic: php general
Replies: 1
Views: 461

Re: php general

Sure, you can use implode for example :-)