sql connection problems

Problems with the Windows version of XAMPP, questions, comments, and anything related.

sql connection problems

Postby pyro » 08. February 2005 00:23

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
pyro
 
Posts: 11
Joined: 07. February 2005 03:03

Postby jchapel » 08. February 2005 01:30

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
J Chapel
The application server in my pocket runs on XAMPP
XAMPP Demo http://xampp.no-ip.info
ZPANEL Demo http://zpanel.no-ip.info
jchapel
 
Posts: 25
Joined: 15. January 2005 09:32

Postby Wiedmann » 08. February 2005 10:53

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');
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 148 guests