Page 1 of 1

hollywood 5 and my sql ?

Posted: Mon Mar 05, 2012 3:52 pm
by stefff285
hello andreas hello all

is it possible to communicate with mysql on a server
from hollywood 5 ?

regards

Re: hollywood 5 and my sql ?

Posted: Tue Mar 06, 2012 10:58 pm
by djrikki
Hi stefff285,

Yes, write a php file as normal that expects a list or parameters through the URL.

Quick example:

servername .. "http://www.example.com/"
data$, count = DownloadFile(servername .. "addphone.php?fullname=Fred+Bloggs&phone=0123456789", { File = "T:logfile" })
data$ = nil

OpenFile(1, "T:logfile")
ReadLine(1) ; skip blank line
result$ = ReadLine(1)

debugprint(result$)

>>> echos OK or FAIL

Code: Select all

// addphone.php

if (isset ($_GET['fullname'])) { $fullname = htmlentities($_GET['fullname']); }
if (isset ($_GET['phone'])) { $phone = htmlentities($_GET['phone']); }

// mysql settings
$database="database_name";
$username="root";
$password="root";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$sql = "SELECT *  FROM `table_name` WHERE `Fullname` = '$fullname'";
$result=mysql_query($sql) or die(mysql_error);		
$num=mysql_numrows($result);

if ($num == 0) // this person not found, add to database
{
        $sql = "INSERT INTO `$database`.`table_name` (`Fullname`, `Telephone`) VALUES ( '" . $fullname . "','" . $phone . "' );";
	$result=mysql_query($sql) or die(mysql_error);
	mysql_close();
		
	echo "OK";
}
else
{ echo "FAIL"; }


Re: hollywood 5 and my sql ?

Posted: Tue Mar 06, 2012 11:53 pm
by djrikki
Can't edit post above, couple corrections:

1st line: change .. to = obviously ^.^

2nd line: Change the plus between Fred and Bloggs to a space character as DownloadFile() will complain.

Re: hollywood 5 and my sql ?

Posted: Wed Mar 07, 2012 1:34 am
by stefff285
hello hello

thanx a lot for reply

this kind of feature will take a long time before i will need it
but cool to see what is possible or not

thanx yet

regards

stephane