Jump to content

PHP and MySQL???


Recommended Posts

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???
Link to comment
Share on other sites

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 
Link to comment
Share on other sites

To check PHP is suing the correct php.ini run the phpinfo function in a php file:
[code]<?php
phpinfo();
?>[/code]
Now look for the [b]Configuration File (php.ini) Path[/b] 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.
Link to comment
Share on other sites

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...

[code]
<?php
// 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"; }
else
{
echo "Contact added!";
}

}

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

//stripslashes!!!!!
$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()">
</form>
<? }?>
[/code]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.