Using PHP to get data from SQL Server


#1

Hello

I am a desktop computer database programmer. I have not done any web programming. I need to convert an Access application that uses data from SQL Server. I would like to use HTML to make the app. Can I use PHP to read from the sql server database? There will only be one or two pages tops. I do not need a dynamic page but a static page with a combobox populated with data from SQL Server.

Can this be done with PHP? If so can a link be provided with a sample or tutorial?

Thanks


#2

Even for desktop this would be a dynamic instance. Static is anything that does not change, dynamic would be pulling from the database. If you want static, hand code the values in the dropdown and you are set, if you want it pulling from the database, making it dynamic, yes PHP does that.

Using PHP and SQL Server


#3

OK so then how do you describe the difference between a page that has html code or controls dynamically arranged and / or added to a web page as opposed to a page that never has any changes to the html or PHP.

In other words say there is a page where the code never changes and another page where the code can be different every time?

Its important to understand what people call things if a useful discussion is to ensue.


#4

A static page is going to be the same everytime. In your case, you are loading a select field from a database. It may stay the same, but because it is loading from a database it *could change without someone actually changing the HTML itself, if the database was updated.

Does that make more sense?


#5

I was looking for the terminology to describe the different page types. If you do not know then don’t worry about it.

Perhaps you can explain how to install PHP. I downloaded a couple of versions but it seems they are looking for a micorsoft library, MSVCR110.dll. I ran every executable in the root directory and found no instructions. I tried a test that failed:
[php]

<?php echo "My first PHP script!"; ?>

[/php]

Does anyone know how to install this?


#6

I gave you the terminology describing the difference, you just choose not to listen. For more information

For installing a PHP server you can use
XAMPP
WAMP

Take your pick. They will install what you need to run PHP. You could also lookup how to run PHP under IIS, but it causes it’s own headaches.


#7

You described a page where the code gets dynamically built as a dynamic page.
You also described a page where the code is static with a combobox with dynamic data as dynamic.

Not sure how you can say dynamic is different from dynamic. You provided the same definition for both page types. You are describing the difference between dynamic and static, not the differences I asked for.

Again, if you go back and read the post again you may understand the question. If you need clarification please ask. When someone repeats a question that is an indication that you either did not understand what was being asked or did not provide an appropriate answer.

Thanks for the links, I will check them out.


#8

Both those links install MySQL. That is not desired. So unfortunately I am still looking for a way to install PHP.


#9

That is what a LAMP stack is. You can then connect to sql server if you have one of those.

Php requires a server to run, a LAMP stack is the easier way to do that.


#10

Thanks for your help. It is starting to look like PHP is a poor choice for this project. Having to install a database that is not wanted makes this a less than desirable choice. Requiring a server when one is not needed adds extra complexity that produces no benefits.

So it looks like ruby, perl or python my be my best choice. After a quick glance it looks like I will have to generate the whole page with the script which is better than the extra overhead required by PHP.

Any suggestions on which one to use?


#11

What are you trying to do? Is it for a company portal or something that will be running on a server or something that will be running from a desktop? Granted you said you were a desktop database person, not sure what that is outside of Access, but take what the project needs now and what it may need in the future into account.

Any of those is going to require an interpreter for whomever uses it. The other side of the coin is what do you know? Are you going to have to learn the language to make the program? What languages do you know that you could leverage for the project?


#12

I want to use html running on a desktop to receive user selections from a database (get a drawing based on a part number or other specifications). There is no portal, no server other than the database server required.

There will never be any internet access for this project since government export regulations prohibit access to the drawings, so it will always be local. Initially it will be run on a desktop. I want to use HTML to make it platform independent for possible tablet access in the future.

As for web programming I am ignorant in that department. I know a little HTML and javascript but I read that javascript should not be used for database access. Besides I used javascript very little and I have used none of the mentioned languages for database access.

A desktop programmer is someone who write programs to run on a PC. Add to that a database and you have someone who creates forms for CRUD (Create, Read, Update and Delete). I’ve been in a windows environment and a VB programmer with SQL (T-SQL). I can also code in C# which is almost identical to VB .Net with about a dozen commands that are different but function similar. I have used about a half dozen other languages to various extents.


#13

I do .NET and Linux and I had TS SCI clearance so I understand where you are coming from…

I would do this as a VB project to get it up quickly, if speed is a factor, otherwise stick with C# on the desktop. The tablet it going to be harder. To make it mobile accessible, it will have to be hosted on a server, unless you wanted to host a REST API that would be able to interact with both parts.

For what you want, you are not going to be able to use HTML only. Javascript cannot directly access a server and a desktop cannot run PHP without a server.


#14

PHP will work for you, JohnM if you listen to what Astonecipher is telling you. Here’s a recap…

.NET runs on a server or as an application on a desktop. (Access runs as an application.)
HTML runs inside a browser, but, MUST link to a server if it is to pull data from a database.
PHP runs on a server.

The two links for Xampp and Wamp, I use Wamp, either is good, is an install that will install a server
on your desktop, install PHP inside the server, install MySQL on the server and you can “serve” your
HTML files to anyone on your LAN. Since you said you already have a SQL set up, you should be able
to use the correct connection strings to link them together and it should all work. Note that both the
Wamp and Xampp systems are comparably small downloads to do all of this and work well on a desktop.
They only need a small learning curve which is a good thing. Once set up, you can turn the server on or
off with ease which will secure the files somewhat.

Astonecipher has given you all you need to do this. Hope this recap helps you understand it a bit better.
Good luck with your project…


#15

Yes I know I can not use HTML only. That is why I asked about ruby, perl and python in the first place. (Hint: a programmer would not ask questions on a PHP forum if they are trying to use HTML only). It seems you are not following the discussion. I am way ahead of you on this.

If speed was a factor I would’ve already made a front end. Speed is not a factor. We have a working app. Creating a VB project is pointless as is C#. Not sure why you are side-stepping the issue or making up questions that have not been asked. I understand you may like thinking about solutions, but you do not have the facts to come up with the answers you are providing. If you really want to help try to stay on topic. I was hoping you could help answer a question, but deviating like you are does not help.

And I don’t think it requires a server. I can make an app with javascript and html and copy it to a machine. Viola, done with out a server to deliver the page. I fail to believe adding DB access to that design requires anything more than a dataaccess layer and script processer, again without a server. Remember just because you do not know how to do something does not mean it can not be done.

Thanks but I don’t think you understand the scope of the project.


#16

Thanks Ernie but there are a couple of issues.

  1. MySQL is extra baggage that is not wanted. Extra complexity.
  2. The HTML files do not need to be “served.” Extra complexity

It is not wise to do unwanted things just to use PHP when another option accomplishes the same thing without the unwanted overhead. I am looking for a solution, not a way to force the use of PHP .

Right now it seems it may be better to use ruby, pyhton or perl. Then I do not need an extra server. I do not need to install a database that will never be used. Maybe I’m wrong, but I would be wrong if I didn’t explore an alternative that initially appears to have less overhead and more closely matches the required solution.

Thanks again.


#17

JohnM,

You started with wanting to covert an ACCESS app to use in HTML. Javascript and ANY
CLIENT-SIDE browser language is not secure. Very few programmers would use that to serve out
data from a database. In most companies, Java is turned off for security reasons.

But, it appears you have solved your our way to handle it. Good luck with your project.

PS: Wamp takes very little “overhead”. MySQL on my Win8 system running right now takes 24megs of ram.
And, no cpu unless doing a huge query. And, it lets me run more standard web apps locally. So, I guess it is
one of those “In the eye of the beholder” things…


#18

You have the whole smartest person in the room when you don’t know what you are talking about.

  1. PHP requires a server to use it. You seem to think otherwise.
  2. RoR would be the same issue.

I don’t have the full scope of the project, but I know the tools I use on a daily basis and know their limitations. You on the other hand state you know how to use .NET products and jump to PHP, a language you obviously don’t understand, when ASP would serve your purpose.

I have been a developer for a bit and know people in IT that have been in the industry since it was created and have never heard of a desktop database programmer. Almost every application uses a database, but they are not included in the title. You would be classified as a .NET developer, and I have doubt on that with your wanting to do this in Linux languages.

Have fun on your project, maybe you can show the IT department at rotair and get in to the department you covet. I’m done with this topic.


#19

I think it is wise you are done. You constantly miss the point.

Not sure why you think you’re the smartest person in the room when you can’t follow a simple question. I suspect it is an ego problem.

I stated I do not want to use PHP because it requires a server. Don’t know where you got that idea from. Again you have make the same error over and over again in this thread. You don’t listen to the question and insist you have useful input to something you fabricate in your own head. You may be helpful to others if you listened to the question instead of trying to promote your own beliefs.

Also I never said my title was a desktop database programer. Again, you decide to make things up to suit yourself. I was telling you what I did. I suggest you read posts before you reply and not create things to make them how you wish them to be. All that does is serve yourself.

Now I see why you spend so much time posting to threads. You don’t have enough work to keep you busy. Perhaps if you improved your communication skills people may hire you.


#20

Well, JohnM, sorry if your feathers get so ruffled.

But, again, PHP can run on a desktop with little overhead. And, it works great with a database.

.NET runs great on a desktop and works well with a database, but, uses a lot more overhead in my
humble opinion. Javascript is not really a database programming language although it will do that job
just fine. But, it also is less secure as it’s code can be grabbed and might open up wholes in your
security.

Since you never told us what you really are attempting to do, I would have to guess it is for a local
area network so others in the group can access the database. If so, JS would probably be just fine
as the other user’s are local and not a big security threat.

If you are happy with your decision to go with Javascript, let us know and I will mark this thread solved.

But, please feel free to come back if you encounter another issue with your code. Perhaps next time we
can assist better then…