Jump to content

Don Jajo

Members
  • Posts

    58
  • Joined

  • Last visited

Posts posted by Don Jajo

  1. Because you initiated MySQL connection with MySQLi procedural method and you tried executing the query with OOP method that is why it keeps dying :)

    Let your $con be

    <?php $con = new MySQLi('db_host','db_dbuser','db_pwd','db_name');?>

    or let your query execution be procedural

    <?phpmysqli_query($con,$SQL) or die('error');?>
  2. Thanks to justsomeguy, I just learnt new thing now :)

     

    Now the PHP_SELF fetch URL from the address bar, if am using something like

    <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"><input type="text" name="" /></form>

    and in the address bar I add this (assuming my file is test.php)

    test.php/" <script>alert('hello');</script>

    Check the ouput now :)

  3. Another thing - Is it possible to run this same script several times on one page with different text files?

    I could repeat the whole script each time of course, but I thought there might be a way to have the full script once at the top then have a short line that can call it with a file name variable...

    (like what you'd do with a javascript function)

    The above code can work quite well since the content is of each line

  4. No, the ($content !== null) still includes the blank lines?

    Ye, during the explode it also explode empty lines to array thereby making $content to be null. Now am making it show all lines which the content is not null :)

  5. Quite well :) seems you don't need the <li> elements because you are replacing it in the output. And for the blank lines, for effective results i suggest you also add it to the foreach loop. Like:

    foreach($text_contents as $content) { if($content !== null) {  $check_url = parse_url($content);	//if its a URL add the <a ...	if(isset($check_url['host'])) {		$content = '<br/><a href="'.$content.'">'.$content.'</a>';	} 	//Add <li> to all content and pack them back to array	$output[] = '<li>'.$content.'</li>';}}
  6. This should work out :)

    <?php$text = $text = file_get_contents('list.txt'); // get contents of file//Explode new lines to array$text_contents = explode("n", $text);//Run a foreach to manipulate an array valueforeach($text_contents as $content) {	$check_url = parse_url($content);	//if its a URL add the <a ...	if(isset($check_url['host'])) {		$content = '<a href="'.$content.'">'.$content.'</a>';	}	//Add <li> to all content and pack them back to array	$output[] = '<li>'.$content.'</li>';}//Expload array back to stringsecho implode('', $output);?>
  7. in my projects I do them like these:

    <?phpdefine('ABSPATH',dirname(__DIR__));?>

    or

    <?phpdefine('ABSPATH','/home/user/public_html/');?>

    When including i now use

    <?phpinclude(ABSPATH.'file.php');?>
  8. I've wrote this once, try this

    $email = $_POST['email'];		$subject = $_POST['subject'];		$message = $_POST['body'];		$filename = $_FILES['file']['name'];		$size = $_FILES['file']['size'];		$mime = $_FILES['file']['type'];		$tmp = $_FILES['file']['tmp_name'];		$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";$file = fopen($tmp,'rb');							// Now read the file content into a variable							$data = fread($file,filesize($tmp));							// close the file							fclose($file);							// Now we need to encode it and split it into acceptable length lines							$data = chunk_split(base64_encode($data)); // Now we'll build the message headers						$headers = "From: $emailrn" .						"MIME-Version: 1.0rn" .						"Content-Type: multipart/mixed;rn" .						" boundary="{$mime_boundary}"";						// Next, we'll build the message body note that we insert two dashes in front of the MIME boundary when we use it						$message = "This is a multi-part message in MIME format.nn" .						"--{$mime_boundary}n" .						"Content-Type: text/plain; charset="iso-8859-1"n" .						"Content-Transfer-Encoding: 7bitnn" .						$message . "nn";						// Now we'll insert a boundary to indicate we're starting the attachment we have to specify the content type, file name, and disposition as an attachment, then add the file content and set another boundary to indicate that the end of the file has been reached						$message .= "--{$mime_boundary}n" .						"Content-Type: {$mime};n" .						" name="{$filename}"n" .						//"Content-Disposition: attachment;n" .						//" filename="{$fileatt_name}"n" .						"Content-Transfer-Encoding: base64nn" .						$data . "nn" .						"--{$mime_boundary}--n"; 						mail('yourmail@mail.com',$subject,$message,$headers);						echo 'Mail Sent!';
  9. Hi,

    Sessions can't work if the clientside doesn't want it to work by disabling their cookies ;)

    So since it works normally and later on messes up which may be because the clientside has no cookie enabled browser :)

×
×
  • Create New...