Posted September 7th, 2010 by ihs
Hey all, recently purchased vsPHP and I am having the error mentioned in the title.
Here is the very simple code which was tested in Netbeans and worked correctly:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Waddup mayn</title>
</head>
<body>
<?php
$host
="localhost";
$username="root";
$password="[password]";
$database="simpletest";
$table="users";
$con = mysql_connect($host,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query("SELECT * FROM $table" );
while(
$row = mysql_fetch_array($result))
{
echo $row['index'] . " " . $row['name'];
echo "<br />";
}
mysql_close($con);
?>
</body>
</html>This is on top of days of trying to figure out how to run a PHP web service from vsPHP using VS2010 on a simple localhost. I'm tying to connect this webservice to MySQL.
All this will eventually work with Silverlight (hence why I'm not sticking with Netbeans and prefer my PHP service within VS).
I am using IIS.
So can anyone please tell me step by step what kind of Project I have to create in VS2010 with the vsPHP plugin to run a PHP web service successfully on my localhost and connect it to MySQL?
Thanks a lot for ANY help!
juanc says:
Looks like you are using your own web server instead of the built-in one. Is that correct?
ihs says:
It is correct, yes.
Just the simple localhost server running through Wampserver.
1) Is this not possible or can I make it possible by adjusting .ini files/ VS2010 settings?
2) If not, how do I use the built-in one? And if I do, is it possible to link to MySQL database sitting on localhost?
I want VS2010 to hold my app and PHP service and when I run, that PHP service to connect to localhost/ MySQL.
After the app is 'finished', this will connect to a remote server to be used by a company.
ANY help on how I get this running (I'm only worried about locally at the moment) is hugely appreciated.
juanc says:
Probably the best thing to do is to use the built-in web server. This is the default behavior anyways...
Create a new project and do some very simple PHP code and hit F5 so you get familiar with how the built-in web server works.
Then you can create a new project from existing folder (maybe that's what you did?)
BTW, the built-in engine can use PHP 4, PHP 5.2 or 5.3 so make sure you create the correct project.
Juan
ihs says:
That's the thing, I CAN'T use the built in server, I pasted the very simple code you see in the first post in to a brand new PHP 4,5.2, AND 5.3 project, pressed F5 and it gets stuck on "Connecting..." for ages and then gives this error (on IE): http://i53.tinypic.com/erehw9.png
Everything connects fine when I run it through Netbeans and I don't get any of those errors.
Check the connection info on my code, do I need to change that to make it work with built-in server? Do I need to open a port?
What do I need to do to make this work? Why doesn't it work...
I've spent almost a week on this now....Can't get started on coding my app because I can't even run a simple PHP so please help.
juanc says:
If you have this script already running on IIS, all you need to do is enable XDebug in your php.ini file.
Look at the one created by the built-in engine in the project dir for the entries you need to add to your php.ini file.
ihs says:
Oh ok, now that I linked my php.ini in the project properties (I am such a newbie I hadn't even done that), most errors are gone and now it says there is misconfiguration (exact error just in case: http://i55.tinypic.com/2pobq4y.png ) which what you suggested will hopefully fix **BUT**, where is the part I have to paste into php.ini and where in the php.ini do I paste it?
Thanks for your help so far, thanks to you I'm finally getting somewhere and this may very well be the last hurdle so please help with this as well.
juanc says:
Actually that made it worst. Are you using the built-in engine?
Is there anything special in your php.ini file that you need?
Juan
ihs says:
EDIT: Scratch all this, I have been a major fool.