mysql
Re: mysql
Yep, you can communicate with mysql through PHP files on a webserver (With HTTPRequest) ( https://www.spiderbasic.com/documentati ... index.html)
or you have SQLite (client side database) directly in SpiderBasic ( https://www.spiderbasic.com/documentati ... index.html )
or you have SQLite (client side database) directly in SpiderBasic ( https://www.spiderbasic.com/documentati ... index.html )
Re: mysql
SpiderBasic code :
PHP file ( PostData.php ) :
Code: Select all
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
Procedure PostProject(id,name.s)
params.s = "?&id="+Str(id)+"&name="+name
HTTPRequest(#PB_HTTP_Post, "PostData.php", params.s, @HttpGetEvent())
EndProcedure
PostProject(184,"SpiderBasic")
Code: Select all
<?php
$id = isset($_POST['id']) ? $_POST['id'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : '';
var_dump($id);
var_dump($name);
?>
Re: mysql
Sorry to revive this thread.
I've tried the above method - deployed it to my webserver and all i get is a blank screen with a blue background.
I've also tried changing the line :
to
but get the same error.
Any ideas where i'm going wrong.
cheers
I've tried the above method - deployed it to my webserver and all i get is a blank screen with a blue background.
I've also tried changing the line :
Code: Select all
HTTPRequest(#PB_HTTP_Post, "PostData.php", params.s, @HttpGetEvent())
Code: Select all
HTTPRequest(#PB_HTTP_Post, "http://myserver/PostData.php", params.s, @HttpGetEvent())
Any ideas where i'm going wrong.
cheers
Re: mysql
Hi Peter,
Sorry for the lack of info.
The SB program throws 'HTTPRequest(): Error' in the debug window when compiled from within SB, whicj is why i pointed directly to the PHP on the server.
When I compile it and deploy it to my server I just get a blank default blue background and nothing else.
I'm not a PHP/ajax virgin, but don't understand CGI at all, but would really benefit from a simple demo of a SB getting data to/from a mariadb/mysql database on a server cos i really can't seem to get my head around how this works in real time.
Anyway thanks for looking.
Sorry for the lack of info.
The SB program throws 'HTTPRequest(): Error' in the debug window when compiled from within SB, whicj is why i pointed directly to the PHP on the server.
When I compile it and deploy it to my server I just get a blank default blue background and nothing else.
I'm not a PHP/ajax virgin, but don't understand CGI at all, but would really benefit from a simple demo of a SB getting data to/from a mariadb/mysql database on a server cos i really can't seem to get my head around how this works in real time.
Anyway thanks for looking.
Re: mysql
If you open the developer console of your browser (usually by pressing the F12 key) and then switch to the Network tab, you will see a more meaningful error message.
Greetings ... Peter
Greetings ... Peter
Re: mysql
First up thanks to everyone for the help so far.
I now have a working form that will display requested information upon a button click and getting the data via a PHP script
So my next question is what is the best way to parse the data being returned back.
I've never used JSON although i've seen it referenced quite a bit on the forum, but don't quite see how it fits into parsing the retuned data ?
i tried modifying an example in SB but it's not working and wonder if anyone here can offer some advice
i'm actualy echo'ing the data back through the PHP script so this may not be the best way to acheive this.
Thanks
I now have a working form that will display requested information upon a button click and getting the data via a PHP script
So my next question is what is the best way to parse the data being returned back.
I've never used JSON although i've seen it referenced quite a bit on the forum, but don't quite see how it fits into parsing the retuned data ?
i tried modifying an example in SB but it's not working and wonder if anyone here can offer some advice
Code: Select all
LVAR_text.s
If ParseJSON(0, Chr(34) + Result$ + Chr(34))
For i = 0 To JSONArraySize(JSONValue(0)) - 1
LVAR_text + GetJSONString(GetJSONElement(JSONValue(0), i)) + #CRLF$
Next i
Else
JSONErrorMessage()
EndIf
SetGadgetText(GVAR_a, Result$)
Thanks