Why i can't connect to my database??

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
User avatar
x_sky58
New php-forum User
New php-forum User
Posts: 49
Joined: Thu Jun 16, 2005 5:38 am

Tue Jul 12, 2005 1:35 am

When i open click on submit button,then the browser pop out this message:

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\dbconnect.php on line 2

this is the index file'code (file name:sign.php):

Code: Select all

<HTML>
<TITLE>let's sign in</TITLE>
<HEAD
<BODY>
<h2>Sign in to myt guestbook!</h2>

<form method=post action="create_entry.php">

<b>Name:</b>
<input type=text size=40 name=name>
<br>
<b>Location:</b>
<input type=text size=40 name=location>
<br>
<b>Email:</b>
<input type=text size=40 name=email>
<br>
<b>Home page URL:</b>
<input type=text size=40 name=url>
<br>
<b>Comments:</b>
<textarea name=comments cols=40 rows=4 wrap=virtual></textarea>
<br>

<input type=submit name=submit value="Submit">
<input type=reset name=reset value="Reset">

</form>


then the create_entry.php code:

Code: Select all

<?php include("dbconnect.php");

if($submit=="Submit")
{
  $query="insert into guestbook
  (name,location,email,url)values
  ('$name','$location','$email','$url')"
  ;
  mysql_query($query) or
  die (mysql_error());
?>
<h2>Thanks</h2>
<h2><a href="view.php">View my guestbook!</a></h2>
<?php
}
else
{
  include("sign.php");
 
}

?>


then dbconnect.php code:

Code: Select all

<?php
mysql_connect("localhost","guestbook","mysql") or
    die ("Could not connect to database");
mysql_select_db("guestbook") or
    die ("Could not select database");

?>


any teacher,please help me to solve this problem...

thank you......[/code]

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Tue Jul 12, 2005 2:05 am

easy: you simply need to enable php_mysql.dll in your php.ini extention section :)
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests