- Mitko Kostov
...or you can go in php.ini and set the output_buffering=On ( it's Off by default)
... or use ob_start();
- Mitko Kostov
Hello.
There is no syntax error in this code, but
if you want to check a value of variable you
must use operator "==", not "=".
- Mitko Kostov
Hello.
If you have form like this:
<form action="check.php" method="post">
<input type="text" name="username" value="">
<input type="text" name="password" value="">
<input type="submit" name="submit">
</form>
...you can access form values like this:
$_POST['username'] // username
$_POST['password'] // password
- Mitko Kostov
You can use PHP function to convert 'YYYY-MM-DD' to 'DD-MM-YYYY' :
function convertDate($date) {
$new = explode("-",$date);
$a=array ($new[2], $new[1], $new[0]);
return $n_date=implode("-", $a);
}
- Mitko Kostov
You should save the file with php extension.
- Mitko Kostov
Pritaeas, you are rigth. My bad.
- Mitko Kostov
I was wrong posted the code above in a hurry.
You can use :
echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
echo 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo 'http//'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
- Mitko Kostov
URL of the current page :
$current_url = $_SERVER['REMOTE_ADDR'].$_SERVER['PHP_SELF'];
echo $current_url;
- Mitko Kostov
You can use
mail($recipient, $subject, $message, "From:". $sender."\nContent-Type: text/html; charset=iso-8859-1");
- Mitko Kostov
I recomend you to download and install as Ezzaral wrote WAMP. It's easy to use and configure.
- Mitko Kostov
What software do you use ? Pure Apache and PHP installation or all-in-one packet such as WAMP, XAMPP...
- Mitko Kostov
Hello.
You can do it that way:
index.php
<?php include("functions.php");
$title = checkPage($_GET['page']);
?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php $page.=".php";
include($page);
?>
</body>
</html>
functions.php :
<?php
function checkPage($arg) {
switch ($arg) {
case "home":
$title = "Home";
break;
case "downloads":
$title = "Downloads";
break;
}
return $title;
}
?>
If you want to include page downloads.php for example - > index.php?page=downloads.
This is just a simple guess and you can find other way.
- Mitko Kostov
Sorry for the double post, please some mod to delete this.
- Mitko Kostov
Hello.
I think that you have not installed and configured web server and php.
This is the only reason for not executing your php code.
- Mitko Kostov
PHP 4 end of life announcement
[13-Jul-2007]Today it is exactly three years ago since PHP 5 has been released. In those three years it has seen many improvements over PHP 4. PHP 5 is fast, stable & production-ready and as PHP 6 is on the way, PHP 4 will be discontinued.
The PHP development team hereby announces that support for PHP 4 will continue until the end of this year only. After 2007-12-31 there will be no more releases of PHP 4.4. We will continue to make critical security fixes available on a case-by-case basis until 2008-08-08. Please use the rest of this year to make your application suitable to run on PHP 5.
For documentation on migration for PHP 4 to PHP 5, we would like to point you to our migration guide. There is additional information available in the PHP 5.0 to PHP 5.1 and PHP 5.1 to PHP 5.2 migration guides as well.
I was about time ;)
echo $_FILES['file1']['name']; // Name
echo $_FILES['file1']['size']; // Size
... http://www.php.net/features.file-upload
- Mitko Kostov
Hi.
Please, post some code.
Backup :
$command = "mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]";
Restore :
$command = "mysqldump -u [username] -p [password] [databasename] < [backupfile.sql]";
system($commmand);
- Mitko Kostov
If you are allowed to use exec() then that will make it a one line script. Otherwise you can't access mysqldump directly through PHP.
... or system() :cool:
Hi.
I don't think it's good, but at least works form me.
- Mitko Kostov
This I wrote a function for my purpose, it simple but works for me :
function genQuery() {
$row_names = array("name","email","phone","title");
$post_values = array($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['title']);
$num = count($post_values);
$sqlString = "SELECT * FROM t WHERE";
for ($i=0;$i<$num;$i++) {
if (empty($post_values[$i])) { $sqlString.=""; }
if (($post_values[$i]) && ($i==0)) { $sqlString.=" $row_names[$i] LIKE '%$post_values[$i]%'"; }
if (($post_values[$i]) && ($i!=0)) { $sqlString.=" $row_names[$i] LIKE '%$post_values[$i]%'"; }
}
$sqlString = preg_replace("/%'/", "%' AND ", $sqlString);
$len = strlen($sqlString);
$len=$len-4;
$sqlString = substr($sqlString, 0 , $len);
return $sqlString;
}
I want elegant way to check and generate.
Now think that we have 15 fields to check. Is there an easy way to check ( loop maybe ) ?
The previous post is wrong, I'm sorry.
I cannot edit it.
Yes, that's right. But what if $_POST is not set ? And what if there are more fields to check ?
if (isset($_POST['name'])) { $query.="WHERE name LIKE '%$_POST'name']'"; }
else { $query.="AND name LIKE '%$_POST['name']'"; }
if (isset($_POST['title'])) { $query.="WHERE title LIKE '%$_POST['title']'"; }
else { $query.="AND title LIKE '%$_POST['title']'"; }
if (isset($_POST['email'])) { $query.="WHERE email LIKE '%$_POST['email']'"; }
else { $query.="AND email LIKE '%$_POST['email']'"; }
Now think that we have 15 fields to check. Is there an easy way to check ( loop maybe ) ?
Hi folks.
I Have a question :
I'm interested how you generate query string to search DB with more than 1 form with LIKE.
For example :
We have $_POST, $_POST, $_POST, $_POST. How do you generate sql query to search with two criteria ( name and phone ) ?
Thanks.
- Mitko Kostov.
<?php
if ($_GET['id'] == 1 && $_GET['lang'] == 1)
{
echo "hello";
}
?>
- Mitko Kostov
Hi again.
Have you tried with fopen ?
PS:
file_exists() : This function returns FALSE for files inaccessible due to safe mode restrictions. However these files still can be included if they are located in safe_mode_include_dir.
Hi.
This function works just fine.
Please post the errors.
Also you can use :
$url = 'http://www.example.com';
$handle = @fopen($url,'r');
if($handle !== false){
echo 'Exists';
}
else{
echo "Doesn't";
}
PS: What is this :
$lines= echo $variable
- Mitko Kostov
Hello again.
I'm not a mind reader.
Please post code with comment on it.
Hello there.
You have a problem in creating relationships in MySQL ?
Error on connecting server, selecting DB, querying tables ?
Please, be more specific.
- Mitko Kostov
Hi, please be more specific ...
- Mitko Kostov
Hello / Hallo / Hola / Ciao / Bonjour / Privet !
My name is Mitko Kostov, 21-year-old student in Technical University Sofia, Bulgaria. Now I work as Junior PHP developer while studying Electronics.
I hope to find help about coding and I'll try to help people with their issues but mostly I want to meet ambitious and good friends with common interests.
PS: I'm sorry for my english.
You should use
$this->msg = $new_msg;
instead of
$msg = $new_msg;
- Mitko Kostov
What is this ?!?
CREATE TABLE data (artist VARCHAR(30), song VARCHAR(30), album VARCHAR(30));
- Mitko Kostov
Hi. You can use :
function printme() {
global $outside;
print $outside; }
- Mitko Kostov