cereal 1,524 Nearly a Senior Poster Featured Poster

While reading ardav solution I thought another solution. Maybe is not clean but it should work:

<?php
function convert($number)
{
	$reverse = strpos(strrev($number),'.');
	$number = (strpos($number,'0') == '0') ? str_replace('0','',$number) : $number;
	
	$n1 = str_replace('.','',$number);
	$n2 = pow('10',$reverse);
	
	$a = gmp_gcd($n1,$n2);
	$b = gmp_strval($a); # display greatest common divisor
	
	return $n1 / $b . "/" . $n2 / $b . "\n";
}

echo convert('0.75');
?>

bye :)

diafol commented: Nice :) +13
cereal 1,524 Nearly a Senior Poster Featured Poster

You can use .htaccess:

order deny,allow
deny from all

put this file inside the folder to protect and no one can access from the web. Source: http://httpd.apache.org/docs/2.2/howto/access.html

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Run this function, is part of your code:

<?php
function unique_salt() {
	return substr(sha1(mt_rand()),0,22);
  }
echo unique_salt() . "<br />";
echo unique_salt() . "<br />";
?>

You will get something like this:

32f2b4c6e1c81629fa6c02
fdbfe19bbbec167eb4c040

This are salt values, and if you refresh you will get more different values. If you store only the password hash on the database then you can't get the right match, you need to store also the salt.

So, for example, if the hash stored is:

$2a$10$ea04e8df85241ceb9157auxKBW3YKOyHa6XDAZkindtKLZ/GiUcdO

in order to work, your script needs the password sent by the form, $algo, $cost variables and the salt generated when the password was registered, so you need to retrieve this last value from the database.

Right now your script is going to generate a new salt value to compare the password, value that's different from the original used for the hash generation. I hope is more clear now, English is not my main language.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can write: $name,$field1,$field2 without quotes. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe is not the best solution but here's an example:

<?php
	$arr = array('1','2','3','4'); # simple array
	function sql_where($a)
	{
                $b = "";
		$n = count($a) -1;
		for($i = 0; $i <= $n; $i++)
		{
			$b .= ($i == $n) ? "`studnum` = '$a[$i]' " : "`studnum` = '$a[$i]' OR ";
		}
		return $b;
	}

	$where = sql_where($arr);
	
        include('con.php'); # include connection
	$query = mysql_query("SELECT class FROM tbl_class WHERE " . $where) or die(mysql_error());
	while($row = mysql_fetch_assoc($query))
	{
		echo $row['class'] . "\n";
	}
?>

sql_where() will output something like:

`studnum` = '1' OR `studnum` = '2' OR `studnum` = '3' OR `studnum` = '4'
sDJh commented: good code +6
cereal 1,524 Nearly a Senior Poster Featured Poster
$a = 20;
$b = 30;
echo $a+$b;

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

I don't know your database structure, so here's an example:

# tables structure
mysql> explain users;
+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| id      | int(9)      | NO   | PRI | NULL    | auto_increment |
| fname   | varchar(50) | NO   |     | NULL    |                |
| lname   | varchar(50) | NO   |     | NULL    |                |
| userid  | varchar(50) | NO   |     | NULL    |                |
| referer | varchar(50) | NO   |     | NULL    |                |
+---------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

mysql> explain blog;
+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| id      | int(9)      | NO   | PRI | NULL    | auto_increment |
| title   | varchar(50) | YES  |     | NULL    |                |
| user_id | int(9)      | NO   |     | NULL    |                |
+---------+-------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

mysql> explain comments;
+---------+--------+------+-----+---------+----------------+
| Field   | Type   | Null | Key | Default | Extra          |
+---------+--------+------+-----+---------+----------------+
| id      | int(9) | NO   | PRI | NULL    | auto_increment |
| message | text   | YES  |     | NULL    |                |
| user_id | int(9) | NO   |     | NULL    |                |
| blog_id | int(9) | NO   |     | NULL    |                |
+---------+--------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

# queries to see what is inside:
mysql> select * from users; select * from blog; select * from comments;
+----+-------+-------+------------+---------+
| id | …
diafol commented: nice - coalesce - like it +13
cereal 1,524 Nearly a Senior Poster Featured Poster

Useful documentation: http://www.ffmpeg.org/ffmpeg.html
You can increase upload timeout in your php.ini, check it.

cereal 1,524 Nearly a Senior Poster Featured Poster

You need double quotes, otherwise $x won't be processed. An alternative is this:

'SELECT * FROM ...WHERE field="blah blah" HAVING field2<'.$x
cereal 1,524 Nearly a Senior Poster Featured Poster

Use EOF:

<?php
echo <<<EOF
<?php echo 'test'; ?>
EOF;
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

Then you can use button tag. Here's an example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
</head>
<body>

<div id="offers">
	<label for="item">Select your item</label><br />
	<button type="button" id="item1" name="item">item1</button>
	<button type="button" id="item2" name="item">item2</button>
</div>

<div id="form"></div>

<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$('#item1').click(function(){
	event.preventDefault();
	$('#offers').css('display','none');
	$('#form').append('<form method="post" action="item1.php"><label for="email">e-mail</label><br /><input type="text" name="email" /><br /><input type="submit" name="getit" value="Get Item" /></form>');
});
$('#item2').click(function(event){
	event.preventDefault();
	$('#offers').css('display','none');
	$('#form').append('<form method="post" action="item2.php"><label for="email">e-mail</label><br /><input type="text" name="email" /><br /><input type="submit" name="getit" value="Get Item" /></form>');
});
</script>
</body>
</html>

Note that due to my limited knowledge of jquery I'm writing all the email form through javascript, but I'm sure someone else can suggest a better & cleaner solution.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try this:

echo "<div class='posterdecoration'><img src='$row[scr1]' width='640' alt='$row[name]' /></div>";
echo (isset($row['scr2'])) ? "<div class='posterdecoration'><img src='$row[scr2]' width='640' alt='$row[name]' /></div>" : NULL;

bye :)

-==Zero==- commented: Thanks For Reply Plz Continue With Me +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Use switch():

<?php

	$a = 'about'; # replace with $_GET['page']
	switch($a)
	{
		case 'about':
			echo 'about page'; #instead of echo you can include
		break;
		case 'contacts':
			echo 'contact page';
		break;
		default:
			echo 'home page';
		break;
	}

?>

name the page index.php and make these links:

http://your.website/index.php?page=about
http://your.website/index.php?page=contact

If you write something else is not a case switch, then the script will echo the default value. If then you want links like this: http://your.website/about then you need to edit the .htaccess file, search for mod_rewrite to get more information.

PixelatedKarma commented: Well written +2
cereal 1,524 Nearly a Senior Poster Featured Poster

To run scripts from the command line check this: http://php.net/manual/en/install.windows.commandline.php

It's simple enough.

To make executables, instead, you need linux and PHC: http://www.phpcompiler.org/

cereal 1,524 Nearly a Senior Poster Featured Poster

If you need bold and colors, then you have to use HTML e-mail. There's an example on the mail() page, look at #example 4: http://php.net/manual/en/function.mail.php

There are some tips to apply CSS and make them work on mail clients, like inline CSS instead of using external or style element. Search on google for html email css.

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

In your page you put the following code:

<?php

if(isset($_GET['p']) && !empty($_GET['p'])){
 $p = $_GET['p'];
 //please put mysql queries and most of the code dealing with mysql in a separate page unlike this one
 $query = "SELECT `content` FROM `your_table` WHERE `id`='$p'";
 if (@$mysql_query = mysql_query($query)){
  if (mysql_num_rows($mysql_query)==1){
   $content = mysql_result($mysql_query, 0, 'content');
  }
 }
}else{
 $p=1;
}

?>

<html>
 <p><?php echo $mysql_result; ?></p>
</html>

This is a simple but insecure way to display page content according to the id of the page. You can make a table and store all the id and content and other stuff.

If you wanna make it secure, please put all the queries and everything dealing with mysql in a separate page and require or include it in your main page.

Sorry, I didn't saw you have already posted a solution. I opened the thread and went away for a bit.. ^_^'

cereal 1,524 Nearly a Senior Poster Featured Poster

Go with Ubuntu Server and install Apache, MySQL and PHP. Here you can read the instructions:

- https://help.ubuntu.com/10.10/serverguide/C/index.html

sergent commented: thanks +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Remove quotes from NOW() and it will work:

"UPDATE users SET timp=NOW() WHERE username='$user'"