hollywood 5 and my sql ?

Find quick help here to get you started with Hollywood
Post Reply
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

hollywood 5 and my sql ?

Post by stefff285 »

hello andreas hello all

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

regards
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: hollywood 5 and my sql ?

Post 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"; }

Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: hollywood 5 and my sql ?

Post 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.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
stefff285
Posts: 230
Joined: Sat Mar 03, 2012 12:59 pm
Location: dijon / france
Contact:

Re: hollywood 5 and my sql ?

Post 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
Post Reply