richieking 44 Master Poster

I dont get you.

How do you start your app.??
Give me how it should work in step by step.

ok ;)

richieking 44 Master Poster

more screen shot

SERVER Waiting for client connection on port 9000
IO::Socket::INET=GLOB(0x87c3b98)Welcome. Sim is ready.
IO::Socket::INET=GLOB(0x87c3b98)enter details

wwwww nnnnn kkkkk lllll iiiii

IO::Socket::INET=GLOB(0x87c3b98)this is usr input: wwwww nnnnn kkkkk lllll iiiii

IO::Socket::INET=GLOB(0x87c3b98)This is priority nnnnn
IO::Socket::INET=GLOB(0x87c3b98)This is Location kkkkk
IO::Socket::INET=GLOB(0x87c3b98)Welcome. Sim is ready.
IO::Socket::INET=GLOB(0x87c3b98)enter details

SERVER Waiting for client connection on port 9000
IO::Socket::INET=GLOB(0x88adb98)Welcome. Sim is ready.
IO::Socket::INET=GLOB(0x88adb98)enter details

The king Jesus 4333 Kingdom
IO::Socket::INET=GLOB(0x88adb98)this is usr input: The king Jesus 4333 Kingdom
IO::Socket::INET=GLOB(0x88adb98)This is priority king
IO::Socket::INET=GLOB(0x88adb98)This is Location Jesus
IO::Socket::INET=GLOB(0x88adb98)Welcome. Sim is ready.
IO::Socket::INET=GLOB(0x88adb98)enter details

Ithink I love this perl
IO::Socket::INET=GLOB(0x88adb98)this is usr input: Ithink I love this perl
IO::Socket::INET=GLOB(0x88adb98)This is priority I
IO::Socket::INET=GLOB(0x88adb98)This is Location love
IO::Socket::INET=GLOB(0x88adb98)Welcome. Sim is ready.
IO::Socket::INET=GLOB(0x88adb98)enter details

Hope you are happy now. ;)

richieking 44 Master Poster

Screen shot brother.

SERVER Waiting for client connection on port 9000
IO::Socket::INET=GLOB(0x87c3b98)Welcome. Sim is ready.
IO::Socket::INET=GLOB(0x87c3b98)enter details
richieking 44 Master Poster

Restart your Activeperl before you run the code ok?

This is working 100%.

I can post a screenshot if you want. ;)

richieking 44 Master Poster
#!/usr/bin/perl -w 

use strict;
use warnings;

sub nap {
    sleep 1;
    }

        use IO::Socket; 
        use Net::hostent;              # for OO version of gethostbyaddr 
    my $PORT = 9000;




        my $server = IO::Socket::INET->new(
                                 LocalAddr => 'localhost',
                                 LocalPort => $PORT,
                                 Proto     => 'tcp') or die ("error connection\n");

        
        
        

    print "SERVER Waiting for client connection on port $PORT\n";

         while ( $server->sockname()) {
             
          $server->autoflush(1);
      print $server, "Welcome. Sim is ready.\r\n";
         ≉##Waiting    

print $server, "enter details\r\n\n";    
≉    ##waiting    
my $nrecord = <>;        
chomp $nrecord;    
&nap;##Waiting    
        
(my $Record,my $Priority, my $Location,my $filename,my $time)= split(m/ /,$nrecord); 
print $server ,"this is usr input: $nrecord\r\n";
    
&nap;##Waiting        
print  $server, "This is priority $Priority\r\n";    
&nap;##waiting    
print $server,"This is Location $Location\r\n";

}

Just run this code.

Happy man ;)

richieking 44 Master Poster

Hay its working. I just installed the module. wait on the line. i am checking other stuffs ok? ;)

richieking 44 Master Poster

check with this http://search.cpan.org/~gbarr/IO-1.25/lib/IO/Socket/INET.pm.

your defination must be like one of this

richieking 44 Master Poster

Did you run this in CMD prompt?

The line 18 got nothing to do with syntax. Check with you module and how you initialize the socket.

I dont have IO Socket , only IO Socket SSl.

just a litle busy with thing but i wanna help you.

The problem is check your socket defination. The rest of the code must work. thats 100%

richieking 44 Master Poster

i meant the tool you are using to write your perl code. Active perl for windows.??

I just dont remember the last time i prog. on windows....

thats all good ;)

richieking 44 Master Poster

Try this ,

I have fix the errors .

#!/usr/bin/perl -w 

use strict;
use warnings;

sub nap {
    sleep 1;
    }

        use IO::Socket; 
        use Net::hostent;              # for OO version of gethostbyaddr 
    my $PORT = 9000;




        my $server = IO::Socket::INET->new( Proto     => 'tcp',
                                         LocalPort => $PORT,
                                         Listen    => 5,
                                         Reuse     => 1) or die "can't setup server";

    print "SERVER Waiting for client connection on port $PORT\n";

         while (my $client = $server->accept()) {
          $client->autoflush(1);
      print $client "Welcome. Sim is ready.\r\n";
         &nap;##Waiting    

print $client, "enter details\r\n\n";    
&nap;    ##waiting    
my $nrecord = <>;        
chomp;    
&nap;##Waiting    
        
(my $Record,my $Priority, my $Location,my $filename,my $time)= split(m/ /,$nrecord); 
print $client ,"this is usr input: $nrecord\r\n";
    
&nap;##Waiting        
print  $client, "This is priority $Priority\r\n";    
&nap;##waiting    
print $client ,"This is Location $Location\r\n";

}

hope it helps ;)

richieking 44 Master Poster

you have a bug in your code.

on line 12,13.

That is not how to read an array.
when reading scalar from array its like this

$foo= $foo[0]

## if its a hash
$foo= $foo{bar};

Allow strict. ok?

what ide are you using?
;)

richieking 44 Master Poster
#!/usr/bin/perl
print "enter details\n\n";
		$nrecord = <>;
		chomp;
		print "this is usr input: $nrecord\r\n";
		($Record,$Priority,$Location,$filename,$time)= split(m/ /,$nrecord);

		print  "This is priority $Priority\r\n";
		print "This is Location $Location\r\n";

i just put on try this piece of your code and it works. check it out.
run this via a cmd prompt. ;)

richieking 44 Master Poster

very strange. My works as expected.
chomp $nrecord before split ok?

And make sure split / / is only a space not more.
:)

richieking 44 Master Poster

Hi,
Before you can work on a data, the user must enter the data or you must have the data source.

on line 6 if the $nrecord takes the cmd arg. The code must work with the split.

OK run the code again and print $nrecord if it contains any data.

;)

richieking 44 Master Poster

John if the user enter the whole stuff, its still easy. ;)

you split them into various variables and do the check like as if they entered one after one after the other.

print " fooo bar fooo";
$line=<>;
($fo,$bar,$loo)= split(m/ /,$line);

you got what you need to check.

richieking 44 Master Poster

Why dont you ask for the details one after the other?

print "Please enter Record number\n"
$record=<>;
check if the number is in range, if not, ( print "please enter record number\n"; again.

2. if all good. you ask for the second and the third.
once you got all, you can print the record or record them where ever you want.

That is if you intend to take input from a CMD line. Try and ask for info one after the other.

;)

richieking 44 Master Poster

Also i think you must have data to cross check with user inputs. thats is

Record 19 Chicago myfile 25.

It can be a \t delimitered file or a DB.

I dont really get what you want but we will get there.

richieking 44 Master Poster

on line 17, please provide the full file path.

if (! -e "/home/foo/$filepath") # That is if the file check is not in the same cwd.
Also re arrange your code as the logic does not flow well.

The recording part. do you intend to record to a plain file or a DB?

Advice ;)

richieking 44 Master Poster

yes . Ryan311,

Please check the upload code i gave you.
The option and how to delete is there.

;)

richieking 44 Master Poster

Because when you upload 10000000000 files with the same name.
You will see and have Only 1 file.

They will over write each other. They must be distinct file names to keep all.

;)

richieking 44 Master Poster
#!/usr/bin/perl -w 
        use IO::Socket; 
        use Net::hostent;              # for OO version of gethostbyaddr 
        $PORT = 9000;

        $server = IO::Socket::INET->new( Proto     => 'tcp',
                                         LocalPort => $PORT,
                                         Listen    => 5,
                                         Reuse     => 1) or die "can't setup server" unless $server;

    print "SERVER Waiting for client connection on port 9000\n";

         while ($client = $server->accept()) {
          $client->autoflush(1);
      print $client "Welcome. Sim is ready.\n";
      print $client "Use 'HELP' for help.\n";
      print $client "Enter the Command:";           
          while ( <$client>) {
            if    (/quit|exit/i)            { exit; }                                     
                                                                                         ########################
                                                                                         ## I DONT SEE ANY FILE READING TO||FROM
            elsif (/"Record 19 Chicago myfile 25"/i ) { print  $client "Recording \n"; } ## ARE YOU READING TO FILE ????
                                                                                         ## IT SEEMS THAT YOU ARE INTERACTING ON SCREEN AND ##SAVING  TO FILE YES?
                                                                                         ########################  
            elsif (/help/i) {                           
              print $client "Command: Record priority location filename time \n"; } 
        else
            { print $client "Command is not supported. \n";}
          } continue { 
             print $client "Command? "; 
          } 
          close $client; 
        }
richieking 44 Master Poster

perl is for nuts!
got so many little tricks. ;)

anyway your code looks very clean ;)

mmm. your appreciation sir.....


;)

mark your query as closed.

richieking 44 Master Poster

Can you at least post any code ???

What have you done so far ??

;)

richieking 44 Master Poster

Hi Nail,

You are using a check that works only on digits/numbers.
Try and use this.

if ($auth ne "Admin"){
 print "foo";

}

This should work ok?

Have fun ;)

richieking 44 Master Poster

i have a problem in moving a file to my root folder. i try to upload same file. only 1 file put in my root folder.

Ryam311,
root folder as /home/ryan311 ???

What OS?. linux?

If you need system root....
You will need root permission. Php can not give you root perm.

richieking 44 Master Poster

ryan311

hi ritchie i have something to ask, in this line

if (mysql_query($query)){
// You DELETE the file You Uploade.
unlink("uploads/$goodFile");
}

it means delete the file in the path?

that is if you want to delete the file just uploaded because you wish to store that in your DB. It is just an option.

richieking 44 Master Poster

ryan311,

My problem is the file is save on the database not on the path. i want it to transfer into upload file folder.

because if the file save in my dbase it get bigger and slowly to retrieve. i have only 1 question richie, is it possible to change the dbase all i want to save is the name, description of the file and the date user upload the file? i want to add name textbox and description textbox.

You can add any data you want about the file into the DB. No limit. Yes its a good practise to save the path into your database and put the file in its folder on your server. This means you must have the folder created during the whole show. This means your script create one folder per user.

i have 1 more to ask

how can i limit each user to 50mb storage space to their upload?

i mean the total storage of all files upload.

thanks ^^,.

Yes you can do that. a piece of cake. you create the folder as i indicated for each user, have the folder name, folder size field in your DB.
During the upload, you check with ...

1. if the folder exist, if not, you create the folder and save the path to the folder into a variable for future use.
2. If the User already got a folder, you run a query to check if the size …

richieking 44 Master Poster

What error do you receive, ??? and what exactly do you need.??

The multi upload script i wrote you can upload any number of files you need.

Why dont you build on it?

richieking 44 Master Poster

Hello pallen,

try this

this works like a search engine script.

// concatenate all your variable like this.
$foo=$bar.$name.$isnd.$momo;
			$query = "SELECT * FROM classics WHERE MATCH  (author,title,year,isbn) AGAINST ('$foo' IN BOOLEAN MODE);

Know that this will work just like how google search engines work. it will pull out fields that has the search words.

You can attach this to the other basic search.
NOTE: if only one field qualifies, it will pull only that.

Explore :)

richieking 44 Master Poster

Look just silent the array or variable with @ sign.

You must have just had apache update lately i think.

USE @ to suppress the warning. its not error. Dont touch your working code ok?

Explore :)

richieking 44 Master Poster

Yes but they are not and wont be disabled by php.

Lets set the record straight. The short tags are one of php selling point.

And no web hosting services will dare to disable that. The short and long tag of php are php.

The asp style is only to show off. Its not part of php core.

explore :)

richieking 44 Master Poster

declare

$count=0; or $count; on line 25.

:)

richieking 44 Master Poster

Hold your breath,

Php tag <?=$foo?> can not be turn off.

this is not asp tag
<% ... %>

Trust me i host up to 468 customers website on my server and i know that any hosting company turning this off will be out of business in 2 minutes.

The php short tags are always available on default. The asp type is optional

;) explore

richieking 44 Master Poster
[form]
[input type='text' name='username' value='<?=$value?>']


[/form]

The little php snippet inside the form input value.

Are you getting the idea??
:)

richieking 44 Master Poster

Why this???

All this concatenations ???

from line 6-14. Writing code like this means you want a bug.

you could do all that in a very simple like this.

$message ="   New Contact Information

$row[FIRST]
$row[LAST]

$row[AGE]
$row[GENDER]

$row[EMAIL]
Cell $row[CELL]
 Home $row[HOME]

$row[CITY]

$row[LOCATION]
$row[TIMEBLOCK]

$row[PREFCTCT] 
$row[COMMENT]
Fitness Goals: 
Lose weight: $row[LOSE] 
Gain muscle: $row[GAIN]
Lean and tone: $row[LEAN]
Injury Rehabilitation: $row[REHAB]
Sports specific training: $row[SPORTS]
Overall fitness: $row[OVERALL]
$row[COMMENT]
";

This works and its easier. Arrays from $_POST,$_GET, and from Mysql_fetch_array can work like this without the '' and "".

richieking 44 Master Poster

And make things easier for your self in the future.

learn how to insert php quick tags in html.

Very handy :)

richieking 44 Master Poster

Its about mail server stuff.

This gives a lot of problems when installing some server cp.
such as gnupanel,baifox and most of them around.

:)

richieking 44 Master Poster

You are everywhere mmm. evstevemd...!!

go baby go ubuntu..!!

but fix this bug. dkimproxy. It is killing ubuntu noob.
We need to keep all the noobies. we need numbers for now not quality.

richieking 44 Master Poster

run in the termial
This should fix the problem.

sudo apt-get install adobe-flashplugin

just cut and paste if you can.

come back for more ;)

Explore:)

richieking 44 Master Poster

What is the ache. 64 or 32 bit.??

richieking 44 Master Poster

Use geany. its in the repository, sudo apt-get install geany.

Comes in handy. also try gedit.

Explore :)

richieking 44 Master Poster

Hi akvlko, there are some logic that does not change. A pagination in 50 years is the same today. The logic remains the same. The beauty is css.

Also, php does not have api for drag and drop. Ajax will.
You can post your ajax script and i will look into it and see if i can assist you on that.

Thats if you want ;)

Explore ;)

richieking 44 Master Poster

This is a simple pagination i wrote few years back. it should work out the box. just change few details including database stuff.

Good luck ;)

Explore ;)

richieking 44 Master Poster
/*	Place code to connect to your DB here.
	*/
	include('config.php');	// include your code to connect to DB.

	$tbl_name="";		//your table name
	// How many adjacent pages should be shown on each side?
	$adjacents = 3;
	
	/* 
	   First get total number of rows in data table. 
	   If you have a WHERE clause in your query, make sure you mirror it here.
	*/
	$query = "SELECT COUNT(*) as num FROM $tbl_name";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages[num];
	
	/* Setup vars for query. */
	$targetpage = "filename.php"; 	//your file name  (the name of this file)
	$limit = 2; 								//how many items to show per page
	$page = $_GET['page'];
	if($page) 
		$start = ($page - 1) * $limit; 			//first item to display on this page
	else
		$start = 0;								//if no page var is given, set start to 0
	
	/* Get data. */
	$sql = "SELECT column_name FROM $tbl_name LIMIT $start, $limit";
	$result = mysql_query($sql);
	
	/* Setup page vars for display. */
	if ($page == 0) $page = 1;					//if no page var is given, default to 1.
	$prev = $page - 1;							//previous page is page - 1
	$next = $page + 1;							//next page is page + 1
	$lastpage = ceil($total_pages/$limit);		//lastpage is = total pages / items per page, rounded up.
	$lpm1 = $lastpage - 1;						//last page minus 1
	
	/* 
		Now we apply our rules and draw the pagination object. 
		We're actually saving the code to a variable in case we want to draw it more than once.
	*/ …
richieking 44 Master Poster

look i need to get a gmail account to see what you are talking about. i have been using my own email system since 2004. what exactly ???

do you need pagination script that got checkbox at the side for delete..?? And a search script to search your info etc...?

sorry i dont use gmail and i really dont have the time to do one. i can only write you few script and some directions. how long have you prog. on php?

richieking 44 Master Poster

Thats not a hard nut. The logic is simple.

Modify this script and check for mime type such as txt,doc and write if statement to upload and insert and delete.

2. for the rest of the file, just save them on the server and save the path into the DB.

You must also generate random file name to help the uniqueness of the files. very simple.

$foo= rand (time(),1234567890);
   // The real file extention.to get the ext you do this.
    
$filename = strtolower($goodfile) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];

// NEW FILE NAME IS 
$newName=$foo.".".$sxts;

The rest of the job thus the mime check,upload,insert are all basic if clauses.

Please explore :)

richieking 44 Master Poster

Are you getting the idea?

richieking 44 Master Poster

<!DOCTYPE html>

<head>

<title>MySQL file upload example</title>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

</head>

<body>

<form action="#" method="post" enctype="multipart/form-data">

<input type="file" name="uploaded_file0"><br>

<input type="file" name="uploaded_file1"><br>

<input type="file" name="uploaded_file2"><br>

<input type="submit" value="Upload file">

</form>

<p>

<a href="list.php">See all files</a>

</p>

</body>

</html>

//very basic script. build on it 

//You need to get the value of the file.

for($i=0;$i<count($_FILES);$i++){
	// 
	$upload="uploaded_file".$i;
	if(empty($_FILES[$upload]['name'])){
	// Do nothing. 
	}
	
	else{  
	 // you do this just incase all the form field was not porpulated.
	$goodFile=$_FILES[$upload]['name'];  /** 
	                                       * You can do all your checks by using $upload.
                                            *  ie. $_FILES[$upload]['mime_type'], $_FILES[$upload]['size'] etc
                                            */     
// Where the file is going to be placed Ofcourse you provide your own path
$target_path = "uploads/";

/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $goodFile); 


// If You intend to save files at the server side.
if(move_uploaded_file($_FILES[$upload]['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "<br/>There was an error uploading the file, please try again!<br/>";
}

// if you want to put inside mysql db

$content= file_get_contents('uploads/'.$goodFile);// uploads is the path you uploaded the file

// go ahead and insert into db. $content
 $content;
$query= "Insert Bla Bla values ($content)"; // Are you following me???????????

//EXECUTE mysql_query to insert. 

if (mysql_query($query)){
	// You DELETE the file You Uploade.
	unlink("uploads/$goodFile");
}

	}
	
}

There are few things you must add. a random …

richieking 44 Master Poster

I think you need new code.
The code you had from whatever source if's looks too buggy to me.

You are looking to insert the file into a DB right.? what is the mime type?

If its not .txt, doc . Then i do not recommend saving into a DB. you can save it on the server side and keep the path in the DB.

Just give more info and i will write you a working script.

richieking 44 Master Poster

When you reconnect to already existing mysql connection, you must select the database you want to work with again.

This is a mechanism in the mysql engine. it drops the database that was already selected as it assumes you want to select a different database.

There was no need for reconnection in your script as you are still using the same DB.

P0lT10n was right.! ;)

Explore :)