MySQL with EasyPHP
Posted: Thu Mar 12, 2015 12:35 am
Good evening
I teach Computing Science in secondary school and I'm trying to create a series of practical tasks for senior pupils. They have already created a MySQL database using EasyPHP and used this successfully to create a database-driven website (due to restrictions on the school network, the pupils run EasyPHP from USB pen drives). I now want them to access the same database from a Livecode program.
I am working with databases and Livecode for the first time and I've encountered problems trying to connect to the database using the following code:
put "localhost" into databaseAddress
put "testDB" into databaseName
put "root" into databaseUser
put "root" into databasePassword
put revOpenDatabase("MySQL", databaseAddress, databaseName, databaseUser, databasePassword) into connect
if connect is a number then
put connect into linkID
answer info "Connected to the database." & cr & "Connection ID = " & linkID
else
put empty into linkID
answer error "Unable to connect to the database:" & cr & connect
end if
This generates the error "Can't connect to MySQL server on localhost(0)". I suspect the issue is that I've not used the full path name of the database but I'm not sure what that is.
I found an earlier post with a similar problem 'MySQL + Localhost using MAMP'. The solution makes use of all 6 parameters associated with the revOpenDatabase function
get revOpenDatabase("mysql", "localhost", "testdb", "root", "root",false,"/Applications/MAMP/tmp/mysql/mysql.sock"
The school PCs run Windows 7 so I'm guessing that the pathname would be something like: "E:/EasyPHP/EasyPHP-DevServer-14.1VC9/binaries/mysql/data/testdb"
However, when I try using this pathname, I still generate the same error message as before.
Any help would be very much appreciated. Many thanks in anticipation.
I teach Computing Science in secondary school and I'm trying to create a series of practical tasks for senior pupils. They have already created a MySQL database using EasyPHP and used this successfully to create a database-driven website (due to restrictions on the school network, the pupils run EasyPHP from USB pen drives). I now want them to access the same database from a Livecode program.
I am working with databases and Livecode for the first time and I've encountered problems trying to connect to the database using the following code:
put "localhost" into databaseAddress
put "testDB" into databaseName
put "root" into databaseUser
put "root" into databasePassword
put revOpenDatabase("MySQL", databaseAddress, databaseName, databaseUser, databasePassword) into connect
if connect is a number then
put connect into linkID
answer info "Connected to the database." & cr & "Connection ID = " & linkID
else
put empty into linkID
answer error "Unable to connect to the database:" & cr & connect
end if
This generates the error "Can't connect to MySQL server on localhost(0)". I suspect the issue is that I've not used the full path name of the database but I'm not sure what that is.
I found an earlier post with a similar problem 'MySQL + Localhost using MAMP'. The solution makes use of all 6 parameters associated with the revOpenDatabase function
get revOpenDatabase("mysql", "localhost", "testdb", "root", "root",false,"/Applications/MAMP/tmp/mysql/mysql.sock"
The school PCs run Windows 7 so I'm guessing that the pathname would be something like: "E:/EasyPHP/EasyPHP-DevServer-14.1VC9/binaries/mysql/data/testdb"
However, when I try using this pathname, I still generate the same error message as before.
Any help would be very much appreciated. Many thanks in anticipation.