Search found 53 matches

by MeroD
Thu Nov 01, 2012 1:59 am
Forum: PHP coding => General
Topic: Which function to encrypt / decrypt password
Replies: 2
Views: 1020

Re: Which function to encrypt / decrypt password

http://www.php.net/manual/en/function.sha1.php

Or:

Code: Select all

<?php
$hashed_password = crypt('mypassword'); // let the salt be automatically generated

if (crypt($user_input, $hashed_password) == $hashed_password) {
   echo "Password verified!";
}
?>
http://php.net/manual/en/function.crypt.php
by MeroD
Thu Nov 01, 2012 1:51 am
Forum: PHP coding => General
Topic: How to submit open source codes?
Replies: 0
Views: 691

Re: How to submit open source codes?

Look at the following article:
http://www.smashingmagazine.com/2009/07 ... ositories/

(Not all sites listed are active anymore--but it may give you a rough idea...)
by MeroD
Wed Oct 31, 2012 11:39 pm
Forum: mySQL & php coding
Topic: join three tables
Replies: 5
Views: 2031

Re: join three tables

The products in a single order can have different manufacturer ids. -> This sounds really confusing. Why is there not a Product_Manufacturer linking table then?

I'm not even going to warrant a guess. Maybe posting up the structure of those three tables would help?
by MeroD
Wed Oct 31, 2012 10:50 pm
Forum: PHP coding => General
Topic: Cannot access public properties?
Replies: 1
Views: 875

Re: Cannot access public properties?

Nope, sorry...

Maybe one of the other OO experts on here can help. Maybe try asking this question on Stackoverflow?
by MeroD
Mon Oct 29, 2012 11:10 pm
Forum: PHP coding => General
Topic: Displaying username in every page..
Replies: 1
Views: 1110

Re: Displaying username in every page..

//set the $_SESSION['signed_in'] variable to TRUE   $_SESSION['signed_in'] = true;  //Put the username values in the $_SESSION, so we can use it at various pages  $_SESSION['username] = ...  //check if the user is already signed in...   if($_SESSION['signed_in'])  {   echo 'Hello' . $_SESSION['usern...
by MeroD
Mon Oct 29, 2012 11:03 pm
Forum: PHP coding => General
Topic: Cannot access public properties?
Replies: 1
Views: 875

Re: Cannot access public properties?

class MyClass {     public $public = 'Public';     protected $protected = 'Protected';     private $private = 'Private';     function printHello()     {         echo $this->public;         echo $this->protected;         echo $this->private;     } } $obj = new MyClass(); echo $obj->public; // Works ...
by MeroD
Mon Oct 29, 2012 10:43 pm
Forum: PHP General
Topic: php/js form return total value
Replies: 1
Views: 682

Re: php/js form return total value

To send a Javascript value to PHP you'd need to use AJAX. With jQuery, it would look something like this:
var variableToSend = 'foo';
$.post('file.php', {variable: variableToSend});



On your server, you would need to receive the variable sent in the post:
$variable = $_POST['variable'];
by MeroD
Mon Oct 29, 2012 10:04 pm
Forum: PHP coding => General
Topic: problem with mysql and form
Replies: 0
Views: 624

Re: problem with mysql and form

Try: mysql_affected_rows

http://www.php.net/manual/en/function.m ... d-rows.php

Also: Check if query was successful before checking for results.

if (!$result) {
die('Insert failed...' . mysql_error());
}
by MeroD
Fri Oct 26, 2012 11:48 pm
Forum: PHP coding => General
Topic: help me identify code parts
Replies: 1
Views: 833

Re: help me identify code parts

He's just using multiple SQL queries instead of joins to get the data from the tables.

Here's a somewhat better tutorial: http://net.tutsplus.com/tutorials/php/h ... m-scratch/
by MeroD
Fri Oct 26, 2012 11:18 pm
Forum: PHP coding => General
Topic: Automatic Page Creation
Replies: 0
Views: 648

Re: Automatic Page Creation

You are probably looking for a blogging platform / content management system:

Try: http://wordpress.org/about/
or: http://drupal.org/features
by MeroD
Fri Oct 26, 2012 11:02 pm
Forum: Free time
Topic: Code Formatting
Replies: 2
Views: 2287

Re: Code Formatting

Oh cool! I kinda missed that :oops:

Since this is a PHP site, can't it just do that automatically? Or at least add a Code[PHP] button?
by MeroD
Fri Oct 26, 2012 12:21 am
Forum: PHP coding => General
Topic: Form update don't work
Replies: 1
Views: 842

Re: Form update don't work

Try tracing the error from mysql:

if (!$risultato ) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $que;
die($message);
}
by MeroD
Thu Oct 25, 2012 10:57 pm
Forum: PHP Scripts
Topic: What is wrong
Replies: 0
Views: 1010

Re: What is wrong

Your Web server should generate some kind of internal error log which gives more details of what went wrong. Try to analyze the applicable logs (if you have access...)
by MeroD
Thu Oct 25, 2012 10:31 pm
Forum: Free time
Topic: Code Formatting
Replies: 2
Views: 2287

Code Formatting

Code: Select all

The code formatting for PHP here really sux :(
Can't it maybe be upgraded to a better (and more readable) standard perhaps?
by MeroD
Thu Oct 25, 2012 10:27 pm
Forum: PHP coding => General
Topic: Php form with mysql
Replies: 9
Views: 2200

Re: Php form with mysql

1. Turn on error reporting to its maximum level while you are developing: error_reporting(E_ALL); 2. Fix mysql: $link = mysql_connect("localhost", "mysql_user", "mysql_password"); mysql_select_db("yourdb", $link); echo mysql_errno($link) . ": " . mysql_error($link). "\n"; 3. Agrees with faust. Indis...
by MeroD
Wed Oct 24, 2012 11:23 pm
Forum: PHP coding => General
Topic: PHP Restrict Access to Page() problem!
Replies: 0
Views: 535

Re: PHP Restrict Access to Page() problem!

Try this logic? <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { // let the user access the restricted page } elseif(!empty($_POST['username']) && !empty($_POST['password'])) { // let the user login } else { // display the login form } ?>
by MeroD
Wed Oct 24, 2012 11:12 pm
Forum: PHP coding => General
Topic: Radio Button to Database Problem
Replies: 2
Views: 664

Re: Radio Button to Database Problem

Code: Select all

$tp = $_POST['type']; // 'type' is set radio button value
by MeroD
Mon Oct 22, 2012 12:08 am
Forum: PHP General
Topic: Useful PHP Articles, Sites
Replies: 50
Views: 35623

Re: Useful PHP Articles, Sites

PHP, a fractal of bad design: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ Don't misunderstand. I'm not trying to put PHP in a bad light, and it is still my 'language' of choice. But the writer of this article raises some valid points that every serious developer should be aware...
by MeroD
Sun Oct 21, 2012 11:11 pm
Forum: PHP General
Topic: mysql_connect and mysqli_connect
Replies: 0
Views: 1221

Re: mysql_connect and mysqli_connect

Please, don't use mysql_* functions for new code. They are no longer maintained and the community has begun the deprecation process. Instead you should learn about prepared statements and use either PDO or MySQLi. http://stackoverflow.com/questions/7206599/switch-to-mysqli-or-stay-with-mysql http://...
by MeroD
Tue Oct 16, 2012 4:51 am
Forum: PHP Scripts
Topic: While loop problem
Replies: 2
Views: 1742

Re: While loop problem

<?php
$i=0;
$j=5;

do {
echo $i . ",";
$i= round($i,1) + 0.2;
if( $i==2 ){break;}
} while ( $j==5 )

?>
by MeroD
Tue Oct 16, 2012 4:18 am
Forum: PHP General
Topic: Check condition in PHP
Replies: 14
Views: 3466

Re: Check condition in PHP

Try looking at:
DATE_FORMAT: http://dev.mysql.com/doc/refman/5.5/en/ ... ate-format

Or try converting the date into a UNIX timestamp. They're easier to store and manipulate in PHP.
$date = mktime ( 0, 0, 0, $m, $d, $y );

http://php.net/manual/en/function.mktime.php