Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Why i can't connect to my database??

Links for php scripts

Moderators: macek, egami, gesf

Why i can't connect to my database??

Postby x_sky58 » 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
<TITLE>let's sign in</TITLE>
<h2>Sign in to myt guestbook!</h2>

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

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

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


then the create_entry.php code:
Code: Select all
<?php include("dbconnect.php");

  $query="insert into guestbook
  mysql_query($query) or
  die (mysql_error());
<h2><a href="view.php">View my guestbook!</a></h2>


then dbconnect.php code:
Code: Select all
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
New php-forum User
New php-forum User
Posts: 49
Joined: Thu Jun 16, 2005 5:38 am

Postby Alexej Kubarev » Tue Jul 12, 2005 2:05 am

easy: you simply need to enable php_mysql.dll in your php.ini extention section :)
User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Re: Why i can't connect to my database??

Postby crm881125 » Wed Jun 22, 2011 6:18 am

I have the same problem as above
I enabled the :

and they are all in my extension folder : c:\php\ext

but it's still giving me :
Fatal error: Call to undefined function mysql_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\DB exercies\lib\opendb.php on line 2

My index file is :
Code: Select all

include 'lib/config.php';

include 'lib/opendb.php';

$user_name = $_POST['user_name'];

$passwd = $_POST['passwd'];

//echo $user_name;

//echo $passwd;

//This script will insert the data to the user table

//you may keep some fields blank

$sql = "INSERT INTO User (User_Name,Passwd) Values ('$user_name','$passwd')";

$result = mysql_quarry($sql) or die ('quarry failed. '.mysql_error());

echo "Insert done";

include 'lib/closedb.php';




<form name="select" action=" " method="post">

User Name <input name="user_name" type="text" />

<br />

Password <input name="passwd" type="text" />

<br />

<input name="button1" type="submit" value="Insert" />




and the included files are :
Code: Select all

//db properties

$dbhost = "localhost";

$dbuser = "root";

$dbpass = "test";

$dbname = "sql_exercises";


Code: Select all

$conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('I cannot connect to  the database becouse: '. mysql_error());

mysql_select_db ($dbname);

User avatar
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Jun 22, 2011 6:06 am

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.