Page 1 of 1

sql connection problems

PostPosted: 08. February 2005 00:23
by pyro
Hi Guys.

I am trying to write my first php script to connect to a sql db

When I go here http://localhost/xampp/simon/temp_con.php

I recieve this message
Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\xampp\simon\temp_con.php on line 3

here is the contence of the temp_con.php
<?php
require ($_SERVER ["DOCUMENT_ROOT"].//config/db_config.php");
$connection = mysql_connect ($db_host, $db_user, $db_password) or die ("error connecting");
echo "connection made";

?>

I am trying to get it to go to this folder \ file
C:\xampp\htdocs\xampp\simon\config\db_config.php where it contains this script
<?php
$db_host = "localhost";
$db_user = "root";
$db_password = "";
$db_name = "askhenry";
?>

I can connect to the db using localhost ( user, "root" ) with no password when using SQLyog or a dos box

what am I doing wrong guys ?

I am loosing allot of hair here as I am pulling it out !!
Cheers again guys

Pyro

PostPosted: 08. February 2005 01:30
by jchapel
Dude your not even close. All you do in those script is define variables.

Code: Select all
<?php
mysql_connect("localhost", "uname", "passwd") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>

Test your server with the examples in the xampp welcome page
If all works

Go thru the tutorial below or one of your choice. READ and go thru examples. The best way to learn and get the experience you need.

http://www.tizag.com/mysqlTutorial

PostPosted: 08. February 2005 10:53
by Wiedmann
Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\xampp\simon\temp_con.php on line 3
Code: Select all
require ($_SERVER ["DOCUMENT_ROOT"].//config/db_config.php");


-->
Code: Select all
require($_SERVER['DOCUMENT_ROOT'].'/config/db_config.php');