LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-01-2005, 12:47 PM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
coding a php server


I am new to coding with php and was wondering if anyone could give me some samlpe code or general code relating to what I need to do. I basically need to request a http script from a vb6 client in windows. On the linux side, I need to setup and http address that recieves four different values from that vb6 client and parse them out giving each a name. The client is set on a timer to send the new value every second so I will need to be able to recieve every second on the php server end. Any help would be greatly appreciated.
 
Old 06-01-2005, 12:58 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If the vbscript is just accessing a url such as:
http://server/script.php?var1=val1&var2=val2

Then the php is:
<?
print "var1 = ".$_GET["var1"]."<br>";
print "var2 = ".$_GET["var2"]."<br>";
?>
 
Old 06-01-2005, 01:03 PM   #3
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
The problem is when the 4 values are passed....the come is as a string all together...ie
(123456, 12.99, 45.876, 0.3456). The need to be parsed out and then assigned names. What would be the code for this?.....Also....is php installed in the knoppix version of linux where I can just go ahead and begin coding?
 
Old 06-01-2005, 01:11 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If they are seperated like that on the query string then:
$var = explode(", ", $_SERVER["QUERY_STRING"]);

$var[0] will be the first number $var[1] the second and so on.

From:
http://ftp.knoppix.nl/os/Linux/distr...x/packages.txt
It looks like it
ii php4 4.3.10-12 server-side, HTML-embedded scripting language (meta-package)
 
Old 06-01-2005, 01:16 PM   #5
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
How do I setup the url on the php side? If possible could you give me a generic template of what the phpcode will look like?

For instance

How to setup the url ect, ect

Step by step?
 
Old 06-01-2005, 01:20 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Quote:
Originally posted by mrobertson
How do I setup the url on the php side?
I'm not sure what you mean by this. Are you asking how to set up a webserver?
 
Old 06-01-2005, 01:24 PM   #7
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
Yes,

I am wondering what is the step by step process to set this up to be able to run. I am sure you have to seclare a url somewhere ........recieve the string.....separate the string(like you already mentioned to me)....then display the values on a url page. I am curious to see a general example of the coding to do this or some source code. I have never done this before and to see something already done, similar to what i need to do would be a big help.


Also do you know if knoppix had php already installed on it and if not how I can install it?
 
Old 06-01-2005, 01:34 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I've never set up a webserver environment in knoppix before but if you are looking for a general LAMP tutorial see:
http://lamps.efactory.de/e-lamps-2-0.php

Once you have set up your webserver save this code as parse.php:
Code:
<?
$vars = explode(", ", urldecode($_SERVER["QUERY_STRING"]));
foreach ($vars as $var){
 print $var."<br>";
}
?>
It can then be accessed as:
http://ip.of.server.here/parse.php?1....876,%200.3456

As I already stated, from the package list it looks like php is included with knoppix.
 
Old 06-01-2005, 01:38 PM   #9
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
Will this be the only code that I will need once I setup the web server in order to pass in the 4 variables?
 
Old 06-01-2005, 01:41 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
It depends what you want it to do.
 
Old 06-01-2005, 01:46 PM   #11
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
Well this program will will be stored on a network cameras memory and the values will be put on the video feed. That is really all I have to do. My client send the updated values every second. Will the php script recive these updates every second or is there another setting or extra coding needed for that?
If so do you know the syntax for this type of thing?
 
Old 06-01-2005, 01:54 PM   #12
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If the client retreives the url every second then the server will receive the values every second.
 
Old 06-01-2005, 01:58 PM   #13
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I appreciate all of your help and very fast responses. I gonna go ahead and give this a shot. Would it be ok if I have any other questions to email you directly? Again thnsk a bunch for you help and patience with me
 
Old 06-01-2005, 02:18 PM   #14
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If you have further questions just post them to the forum, that's what it's there for.

I'm subscribed to this thread so I'll know if you reply.
 
Old 06-02-2005, 08:10 AM   #15
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
David,

I am still having some trouble. I dont really understand how to set this webserver up. Is there any way that you could explain in detail to me exactly where it needs to be set up....vb client or php server and how to do it (ie the syntax). also I tried to at least code the php code into knoppix and got an error on the first line ( <?) saying:

?: No such file or directory


Also after going home and thinking about it yesterday.....my client is setup to passed the variable string through a winsock. Am i going to have to change this or designate a port and host address in php?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding java in a php script mrobertson Programming 44 06-27-2005 01:16 PM
Coding a redirect function in php mrobertson Programming 2 06-22-2005 08:40 AM
php coding with knoppix mrobertson Linux - General 1 06-01-2005 01:30 PM
vim php color coding? Longinus Linux - Software 4 04-11-2004 05:56 AM
PHP maths - coding algebraic formulas linuxfond Programming 2 10-03-2003 01:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration