Jump to content
Larry Ullman's Book Forums

Recommended Posts

hey sir i'm thinking of developing an application with mysql as it's database, i'm wondering if how can i connect that database to my php website? for example i am inputting data on my application (that's on my computer) and saved it. and latter on i want that information to be present on my website too. just like one computer application and a web application sharing at one database. so my question is, have you discussed this on your books? any advice regarding to this topic sir? thank you.

Link to comment
Share on other sites

yeah i have red this before and its really good ,it taught me alot about php and mysql and now i am looking forward to take it to more advance. my very concern here is how will you connect the same database you use in programming application. for example you are programming visual basic and you use mysql as its database how will you connect that database to also use in php web developing. what i mean here is that the database is in your local computer and i want my www.example.com to fetch all informations inputted in my local computer at my home. how can i do that?

Link to comment
Share on other sites

MySQL ties in perfectly with desktop applications. I've never done in Visual Basic per se, but I've done this in Java. A quick online search tells me you need to download the MySQL connector/Net 5.2 from MySQL. This is a driver that will let you connect to a MySQL database. You import this driver into your project, and add a connection function approximately as shown below:

 

Public Sub TestConnection()
    Try
	    Dim connStr As String = "Database=world;" & _
			    "Data Source=YOUR_MYSQL_HOST;" & _
			    "User Id=YOUR_MYSQL_USER;Password=YOUR_MYSQL_PASSWORD"
	    Dim connection As New MySqlConnection(connStr)
	    connection.Open()
	    connection.Close()
	    MsgBox("Connection is okay.")
    Catch ex As Exception
	    MsgBox(ex.Message)
    End Try
   End Sub

 

Switch out the uppercased words with your connect info, just like with PHP. In other words, It's your Mysql host, username, and password. Call the TestConnection() function to perform a connection. Now you can run normal SQL queries against this DB.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...