vibhaJ 126 Master Poster

From Google...

<?php
// ------------------------------------------------------------
function recursive_remove_directory($directory, $empty=FALSE)
{
    if(substr($directory,-1) == '/')
    {
        $directory = substr($directory,0,-1);
    }
    if(!file_exists($directory) || !is_dir($directory))
    {
        return FALSE;
    }elseif(is_readable($directory))
    {
        $handle = opendir($directory);
        while (FALSE !== ($item = readdir($handle)))
        {
            if($item != '.' && $item != '..')
            {
                $path = $directory.'/'.$item;
                if(is_dir($path)) 
                {
                    recursive_remove_directory($path);
                }else{
                    unlink($path);
                }
            }
        }
        closedir($handle);
        if($empty == FALSE)
        {
            if(!rmdir($directory))
            {
                return FALSE;
            }
        }
    }
    return TRUE;
}
// ------------------------------------------------------------
recursive_remove_directory('install');
?>
BadManSam commented: Thanks This Script Worked +0
vibhaJ 126 Master Poster

1) First of all make sure all your href should have seo url, which you finally want
i.e. fullnews.php/123/This-is-the-Headline
So below code will make such href.

function seo($input){
    $input = mb_convert_case($input, MB_CASE_LOWER, "UTF-8"); //convert UTF-8 string to lowercase
    $a = array('č','ć','ž','đ','š');
    $b = array('c','c','z','dj','s');
    //$input = strtr($input, "čćžđšè", "cczdse"); not working properly :(
    $input = preg_replace("/[^a-zA-Z0-9]+/", "-", $input); //replace all non alphanumeric chars with dashes
    $input = preg_replace("/(-){2,}/", "$1", $input); //prevent repeating dashes
    $input = trim($input, "-"); //trim dashes both sides, if any
    return $input;
}
while($row=mysql_fetch_array($sel))
{
$id=$row['id'];
$headline=$row['headline'];
echo "<a href='fullnews.php/".$id."/".seo($headline)."'>$headline</a>";
}

2) Add below code in htaccess file.

RewriteEngine On
RewriteRule ^fullnews\.php/([^/]*)/([^/]*)$ /fullnews.php?id=$1&headline=$2 [L]

So that
The original URL:
http://domain.com/fullnews.php?id=123&headline=asas-asa-as
The rewritten URL:
http://domain.com/fullnews.php/123/asas-asa-as

vibhaJ 126 Master Poster

Try this:

<form method="post" autocomplete="off">
vibhaJ 126 Master Poster

When you insert image in database use chunk_split function as shown below.

$image = chunk_split(base64_encode(file_get_contents($_FILES['fileupload']['tmp_name'])));

After that check, if still it is not working comment below line
// header("Content-type: image/jpeg");

and open get.php in other tab of browser, check if you having any error?

hwoarang69 commented: yeahh +0
vibhaJ 126 Master Poster

Your image's field datatype must be BLOB or LONGBLOB.

hwoarang69 commented: thanks +0
vibhaJ 126 Master Poster

What is datatype of image field in mysql table?

hwoarang69 commented: blob +0
vibhaJ 126 Master Poster

It should be. I think just before few mins you have post all extensions from php.ini and it was there,
Even when you check php configuration from browser (from test.php and code which i have posted above), you will see box for "openssl".

hwoarang69 commented: ty +0
vibhaJ 126 Master Poster

I forget to tell you, if you do any changes in php.ini file, you need to restart your server to see changes.

hwoarang69 commented: so happy this works! +0
vibhaJ 126 Master Poster

Add below code in test.php file and run it in browser, you will see all PHP configuration.

<?php
phpinfo();
phpinfo(INFO_MODULES);
?>

Now look into Loaded Configuration File , it will show php.ini file path.

hwoarang69 commented: ty +0
vibhaJ 126 Master Poster

You need to enable OpenSSL extension.
Edit your php.ini file and remove comma in front of openssl.

extension=php_openssl.dll

hwoarang69 commented: ty +0
vibhaJ 126 Master Poster

Code i have tried:

<html>
<head>
<title>PHPMailer - SMTP (Gmail) basic test</title>
</head>
<body>
<?php
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');
require("phpmailer/class.phpmailer.php");

$mail = new PHPMailer();

$body = "this is <strong>testing</strong> mail ". date('Y-m-d H:i:s');

$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "****@***.com";  // GMAIL username
$mail->Password   = "*****";            // GMAIL password

$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->Subject    = "PHPMailer Test Subject via smtp (Gmail), basic";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);

$address = "youraddress@test.com"; // add your address here 
$mail->AddAddress($address, "Gmail Test");

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}
?>
</body>
</html>
hwoarang69 commented: :) +0
vibhaJ 126 Master Poster

You have blank space in host name.

Also add $mail->SMTPDebug = 2; in your code for debugging.

$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
hwoarang69 commented: ty +0
vibhaJ 126 Master Poster

Once you go live and upload your site on live server it will send email as generally all server supports SMTP.
But if server is restricted, you have to give SMTP settings which will be given by your hosting providers.
Better if you have any live server, upload your test page on LIVE and then test.

vibhaJ 126 Master Poster

If you are working in local system, you need SMTP settings to send email.

Either you can use SMTP credentials as shown here
OR you can use your own Gmail credentials as shown here

vibhaJ 126 Master Poster

Becuse your email message body is not set, you can set it by:

$mail->IsHTML(true);
$mail->Body = $body;
vibhaJ 126 Master Poster

Latest version is v5.2.0, you are using too older version which will not support latest PHP.

hwoarang69 commented: works +0
vibhaJ 126 Master Poster

Which PHPMailer version you are using?? It seems old.
Try to download latest package from http://phpmailer.worxware.com/

hwoarang69 commented: works +0
vibhaJ 126 Master Poster

Try this:

$sql="UPDATE users SET 
        userid = '$_POST[userid]',
        firstname = '$_POST[firstname]',
        lastname = '$_POST[lastname]',
        email = '$_POST[email]',
        username = '$_POST[username]',
        password = '$_POST[password]',
        role = '$_POST[role]'
        WHERE condition = 'value'";
vibhaJ 126 Master Poster

Clear all cookies in browser and then check.

vibhaJ 126 Master Poster

Are you checking in local system? You won't receive email without SMTP.
Once you upload this to LIVE you will get emails.

vibhaJ 126 Master Poster

";

<? while($row = mysql_fetch_array($result)) {  ?>
    <tr>
        <td><?php echo $row['ID']; ?></td>
        <td><input name="txtf" type="text"></td>
        <td><input name="txtf1" type="text" /></td>
        <td><input name="txtf2" type="text" /></td>
    </tr>
<? } ?>
Shougat commented: Thankyou +0
vibhaJ 126 Master Poster

On top of page you need to add session_start().
After that function if you have set any session i.e. $_SESSION['username'] = 'john';you can get it's value on second page by echo $_SESSION['username']; , but make sure on second page you have included sesson_start() function on top of page.

vibhaJ 126 Master Poster

Ohh..
Replace
onClick="$('#full<?=$count?>').toggle("slow");"

with

onClick="$('#full<?=$count?>').toggle('slow');"

vibhaJ 126 Master Poster

This is one of my favorite website: Click Here
Here htaccess code is generated based on your selection, you just need to add it in root of your project.

vibhaJ 126 Master Poster

I was struggling long for proper image resize function for maintaining image ratio.
Finally i end end up with merging and changing all codes and it works !

function resizeImage($sourceFile,$destFile,$width,$height)
sourceFile => Full path along with filename
destinationFile => Full path along with filename

I hope this will help coders..

moonknight33 commented: very good :) +0
vibhaJ 126 Master Poster

Try this:

<?
     while($row = mysql_fetch_array($result)) 
     {
        $one['id'] = $row['id'];
        $one['name'] = $row['name'];
        $one['link'] = $row['link'];
        $one['parent'] = $row['parent'];
        $thisArray[] = $one;
     }
     echo '<pre>';
     print_r($thisArray);

?>
Biiim commented: exact array +5
vibhaJ 126 Master Poster

Make sure any tag doesn't break.
Try below code i have used photourl as image src.

<div class="body2">
  <div class="main">
    <section id="content">
      <div class="wrapper">
        <article class="col1">
          <div id="slider">
            <?php
                while($row=mysql_fetch_array($result))
                {
                ?>
                <img src="<?php echo $row['photourl'] ?>" alt="" title="<strong><?php echo $row['address'] ?></strong><span> <?php echo $row['bathroom'] . " bathrooms," .  $row['bedroom'] . " bedrooms"?> Price: <?php echo $row['price'] ?>     <a href='view-prop.php?address=<?php echo $row['address'] ?>'>Read more</a></span>">
                <?php
                }
                ?>
          </div>
        </article>
      </div>
    </section>
  </div>
</div>
vibhaJ 126 Master Poster

Apart from readymade script, if you still want to make your own code:
1) Design database tables.
e.g
autoId
chatSession
fromUserId
toUserId
message
dateTime

2) There will be one div and one text area for design view.
3) When user type something in textarea and press enter trigger javascript and call ajax to insert textarea's value in database.
make sure you use proper fromUserId and toUserId to insert in database.
4) In div after every 2 sec, call ajax and if there is any new entry in database based on chatSession then show it in div.

vibhaJ 126 Master Poster

Or before <center><font color="white" size=5>, add this line.

<br style="clear: both;">
vibhaJ 126 Master Poster

1) either you need to make all config variable global inside function.
i.e.

function fname()
{
    global $LOCATION;
// now you can use $LOCATION
}

2) or you can define in Setup.inc.php:

define('LOCATION', 'http://www.rest/of/address');
// now you can use LOCATION (without  $ sign) in function file.
turt2live commented: Amazing help +3
vibhaJ 126 Master Poster

Check this code.

<? session_start();
   $sendAfter = (10)*(60); // in seconds 
   $sendEmail = false;
    $now = date('Y-m-d H:i:s');
	
   if(!isset($_SESSION['sent_time'])) // if you are first time send email
   { 
		$sendMail = true;
		$_SESSION['sent_time'] = $now;
   }
   else
   {	
	   $diff = strtotime($now) - strtotime($_SESSION['sent_time']);
	   if($diff >= $sendAfter)// if difference is more than 10 min then only send mail
	   {
	   		$sendMail = true;
			$_SESSION['sent_time'] = $now;
		}
	}
	
	if($sendMail)
		echo "mail sending code here";
	else
		echo "nothing to do";

?>
karthik_ppts commented: useful post +6
vibhaJ 126 Master Poster

Is this like a POLL?
Check this link http://www.codeproject.com/KB/HTML/phpoll.aspx
Try to build some logic and start working on coding part.

vibhaJ 126 Master Poster

what is html code of drop down boxes?
you need to give value to option tag e.g.

<option value="2200">2200</option>
vibhaJ 126 Master Poster

Check this post that how string concatenation works in PHP.
http://www.daniweb.com/web-development/php/threads/369623/1588766#post1588766

vibhaJ 126 Master Poster
vibhaJ 126 Master Poster
IIM commented: helpful +4
vibhaJ 126 Master Poster

Try this.

RewriteEngine On
RewriteRule ^user=([^=]*)$ /profile.php?user=$1 [L]
diafol commented: nice +13
vibhaJ 126 Master Poster

I haven't tried but exec may help you.

exec('/etc/init.d/httpd graceful');
vibhaJ 126 Master Poster

You can also have one single ajax function and pass both user and sex parameter on ajax request.

<html>
<head>
<script type="text/javascript"> 
function showUser() 
{ 
	var users = document.getElementById('users').value;
	var sex = document.getElementById('sex').value;
	
	  if (users=="" && sex=="")
	  {
		document.getElementById("txtHint").innerHTML="";
		 return;
	  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser.php?users="+users+"&sex="+sex,true);
xmlhttp.send();
}
 </script>
</head>
<body>
<form>
  <select name="users" id="users" onChange="showUser()">
    <option value="">Select a person:</option>
    <option value="1">Peter Griffin</option>
    <option value="2">Lois Griffin</option>
    <option value="3">Glenn Quagmire</option>
    <option value="4">Joseph Swanson</option>
  </select>
  
<select name="sex" id="sex" onchange="showUser()">
<option value="">Male/Female:</option>
<option value="1">All</option>
<option value="2">Male</option>
<option value="3">Female</option>
</select>
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>
</body>
</html>

On php side you have two variable GET. users and sex.
You can create sql query based on that.

vibhaJ 126 Master Poster
// select from database and assign it in some variable
if($key == $res['years']) // compare it with looping $key
	$checked = 'checked="checked"';
else
	$checked = '';
<input type="checkbox" name="years[]" <?php echo $checked; ?>  id="years" value="<?php echo $key; ?>"  >
vibhaJ 126 Master Poster

Error is not because of $Title, its because of $_POST.
Write if condition as shown below.

if(isset($_POST['title']))
	$Title = $_POST['title'];

Also you can use error_reporting function to rid of errors.

karthik_ppts commented: yes +5
vibhaJ 126 Master Poster

It will give average of all individual cigars, no matters how may entries.
I forget to group by CigarId.

SELECT CigarId , sum( (
Quantity * Price
) ) / sum( Quantity ) as avg
FROM `cigar`
group by CigarId
karthik_ppts commented: useful post +5
vibhaJ 126 Master Poster

If you are testing this page in local then it won't work.
You need smtp setting for sending email.
For other error post the error you are getting.

vibhaJ 126 Master Poster

@divya: i don't think you can get browser close event.
It works only on some browser, i have tried it in past.
If your code works in all browser post here for others use.

karthik_ppts commented: Yes +5
vibhaJ 126 Master Poster

BTW its different question but how to see that query has examined how many record?
I am having mysql query browser and phpmyadmin.

karthik_ppts commented: Useful question +5
vibhaJ 126 Master Poster

You have placed this code on top.

$query1 = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi1"';
$result1 = mysql_query($query1);
$result1 = $_SESSION['allocate'];

$query2 = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi2"';
$result2 = mysql_query($query2);
$result2 = $_SESSION['alloc'];

That means each time page is refreshed sql query will update record.

You can do it by 2 way.
1) server side
Use submit button.
When user click on submit button page will be posted and top php code will update record. Top php code will be in if condition.
e.g.

if(isset($_POST('submit'))){ //===update query====}

2) Client side
Use Ajax.
Which meanse once user click on button you will send one ajax request to one page which will update data.

vibhaJ 126 Master Poster
<? define('SITE_ROOT_PATH',$_SERVER['DOCUMENT_ROOT'].'testproject/')
include(SITE_ROOT_PATH.'config.php');
?>

You can add above code in any file of any directory of testproject.

vibhaJ 126 Master Poster

How php string works??
In php you can give single quote or double quote for defining string.
If you start with single quote, php will find next single quote for completion of it.In middle you can also use double quote.
Dot(.) is used for two string concatenation.
Same for double quote. If you want to use double quote inside two double quote you can use back slash.
e.g.

'Hi I" am '.'php developer' => valid
'Hi I" am '."php developer" => valid
'Hi I' am '."php developer" => Not valid
'Hi I\' am '."php developer" => valid
'Hi I am '."<a href="http://php.net">php</a> developer" => Not valid
'Hi I am '."<a href=\"http://php.net\">php</a> developer" => Valid

Even if you are using dream-weaver like editor proper string always give red color.
If something is messy, based on color highlighting you can recognize it.

urtrivedi commented: good examples +9
nigelsponge commented: Thank you so much +1
vibhaJ 126 Master Poster

Debug your code with echo.
echo both select script and run it in phpmyadmin.
Post what you are getting.

<?php
					if ($_POST['submit-login'])
{
	$sql = "SELECT * FROM `users` WHERE
	`username` = '" . mysql_escape_string($_POST['username']) . "' &&
	`password` = '" . mysql_escape_string(md5(SALT_KEY .	$_POST['password'] . SALT_KEY)) . "'";
	echo 'First Query : <br> :'.$sql;
	
	$user_retrieve = mysql_query($sql);
	
	if (mysql_num_rows($user_retrieve))
	{
		$ur = mysql_fetch_array($user_retrieve);
		$sql = "SELECT * FROM `user_sessions` WHERE `session_id` = '".mysql_escape_string($_COOKIE['PHPSESSID'])."' && `ip_address` = '".mysql_escape_string($_SERVER["REMOTE_ADDR"])."'";
		echo 'Second Query : <br> :'.$sql;
		exit;
		
		$session_retrieve = mysql_query($sql);
		if (mysql_num_rows($session_retrieve))
		{
			echo "You are already logged in. <a href='members-area.php'>Click Here</a>";
		}
			else
		{
		if (empty($_COOKIE['PHPSESSID']))
		{
		echo "Unknown Error, Please try enabling cookies.";
		}else{
			$create_session = mysql_query("INSERT into `user_sessions` (session_id, ip_address, uid) values ('".mysql_escape_string($_COOKIE['PHPSESSID'])."', '" . mysql_escape_string($_SERVER["REMOTE_ADDR"]) . "', '" . mysql_escape_string($ur['id']) . "');");
			echo "You have successfully logged in. <a href='members-area.php'>Click Here</a>";
		}
		}
		}
		else
		{			echo "Invalid Username or Password.";
		}
	}
?>
vibhaJ 126 Master Poster

You can do this by htaccess.
This is a file named '.htaccess' which you have to put at root of your required project.
You have to write rules in htaccess to generate url.

Visit http://www.generateit.net/mod-rewrite/ to generate simple rules.

diafol commented: cracking link. cheers :) +13