Jump to content


PHP and MySQL???

  • Please log in to reply
5 replies to this topic

#1 dsartain

  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 09 August 2006 - 02:00 AM

I've got PHP 5 installed on my Win2K machine running IIS. I've also installed MySQL...I downloaded the php_mysqli.dll and libmysql.dll files....I put them in the C:\Inetpub\wwwroot\PHP\ext folder....but for some reason PHP still won't talk to MySQL...I've got the extension_dir = "C:\Inetpub\wwwroot\PHP\ext\"  Any ideas anyone???

#2 manmadareddy

  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 09 August 2006 - 05:43 AM

You just need to uncomment that extension in php.ini
Even though if it is not worked means just check whether
it is reading the php.ini correctly then restart the IIS and check.

#3 dsartain

  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 09 August 2006 - 09:21 AM

I have my PHP.ini file as below

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\Inetpub\wwwroot\PHP\ext\"

That should get it done right??  How do I check to make sure it's reading php.ini correctly??  I've tried restarting IIS and nothing changed.  Thanks 

#4 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 09 August 2006 - 09:56 AM

To check PHP is suing the correct php.ini run the phpinfo function in a php file:
Now look for the Configuration File (php.ini) Path line. To the right of that it should state the path of php.ini it is using. If PHP couldn't find the php.ini it will say C:\WINDOWS\php.ini, or if its found the php.ini it should state the correct path to ini file. ALso note when enabling the mysql extension, you'll need to move a file called libmysql.dll to C:\WINDOWS\  (or C:\WINNT if there is no WINDOWS folder).

If PHP is not using the correct move it to the WINDOWS folder, or WINNT if WINDOWS folder doesnt exist.

Also download and extract the zipped bineries version of PHP, rather the PHP installer. Extract the contents of the zip file to C:\Inetpub\wwwroot\PHP overright any existing files. The installer comes with missing files/extensions.

#5 dsartain

  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 09 August 2006 - 04:51 PM

phpinfo(); showed me the correct PATH, I move the libmysql.dll to C:\WINNT...I left the php_mysqli.dll file in C:\inetpub\wwwroot\php\ext...is that right??  I restarted IIS and nothing changed...I'm pasting my code to connect below in case that's an issue...I know PHP works because I can type info into a form, click submit, and then have it display on the next page, it's just the DB stuff that isn't working...

// Declare variables from post //

$firstname = addslashes($_POST['txtFirstName']);
$lastname = addslashes($_POST['txtLastName']);
$address = addslashes($_POST['txtAddress']);
$apt = addslashes($_POST['txtApt']);
$city = addslashes($_POST['txtCity']);
$state = addslashes($_POST['drpState']);
$zip = addslashes($_POST['txtZip']);
$email = addslashes($_POST['txtEmail']);
$phone1_type = addslashes($_POST['drpPhone']);
$phone1 = addslashes($_POST['txtPhone']);
$phone2_type = addslashes($_POST['drpPhone2']);
$phone2 = addslashes($_POST['txtPhone2']);

if ($_POST['stage'] === "insert")
$dbconn = mysql_connect("localhost","dsartain","marines"); mysql_select_db("test2",$dbconn); 
$query = "INSERT INTO `contacts` VALUES('$firstname','$lastname','$address','$apt','$city','$state','$zip','$email','$phone1_type','$phone1','$phone2_type','$phone2')";
$runquery = mysql_query($query,$dbconn);
if (!$runquery) {echo "Query Failed"; } 
	echo "Contact added!";


elseif ($_POST['stage'] === "verify")

$firstname =stripslashes($firstname);
$lastname = stripslashes($lastname);
$address = stripslashes($address);
$apt = stripslashes($apt);
$city =stripslashes($city);
$state = stripslashes($state);
$zip = stripslashes($zip);
$email = stripslashes($email);
$phone1_type = stripslashes($phone1_type);
$phone1 = stripslashes($phone1);
$phone2_type = stripslashes($phone2_type);
$phone2 = stripslashes($phone2);

echo 'Name: ', $firstname.' ', $lastname.'<br /> ';
echo 'Address: ', $address.'<br />';

if($apt != "")
echo 'Apt: ',$apt.'<br />';

echo 'City: ', $city.'<br />';
echo 'State: ', $state.'<br />';
echo 'Zip: ', $zip.'<br />';
echo 'Email: ',$email.'<br />';
echo $phone1_type.' Phone: ',$phone1.'<br />';

if($phone2_type != " ")
echo $phone2_type.' Phone: ',$phone2.'<br />';

<p>Please verify the information you submitted.  If all information is correct press Submit</p>
<p>If not press Edit to go back and correct the information</p>

<form name="Form1" action="database.php" method="post">
<input type="hidden" value="<?=$firstname;?>" name="txtFirstName" />
<input type="hidden" value="<?=$lastname?>" name="txtLastName" />
<input type="hidden" value="<?=$address?>" name="txtAddress" />
<input type="hidden" value="<?=$apt?>" name="txtApt" />
<input type="hidden" value="<?=$city?>" name="txtCity" />
<input type="hidden" value="<?=$state?>" name="drpState" />
<input type="hidden" value="<?=$zip?>" name="txtZip" />
<input type="hidden" value="<?=$email?>" name="txtEmail" />
<input type="hidden" value="<?=$phone1_type?>" name="drpPhone" />
<input type="hidden" value="<?=$phone1?>" name="txtPhone" />
<input type="hidden" value="<?=$phone2_type?>" name="drpPhone2" />
<input type="hidden" value="<?=$phone2?>" name="txtPhone2" />
<input type="hidden" value="insert" name="stage" />
<input type="submit" value="Submit" /><input type="button" value="Edit" onCLick="history.back()">
<? }?>

#6 dsartain

  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 14 August 2006 - 06:05 AM

Ok, I fixed the issue of me not getting any input...the very last line was messed up.  Anyway, now I'm getting an error "Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\PHP\database.php on line 28" when I try to submit the information...

I've got the extension Dir set to --extension_dir = "C:\PHP\ext" --

and the Windows extension is -- extension="C:\PHP\ext\php_mysql.dll" -- 

I've set the ISAPI filter in IIS, I've set the PATH=C:\PHP,

PHPRC as C:\PHP..App Mappings in IIS

.php as C:\Inetpub\wwwroot\php5isapi.dll. 

Is there something I missed??  PHP is still not connecting to MySQL??  Can someone please help?  Thank you.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users