Saving to a SQL Database using php and wamp

hey guys,

Im doing a simple PHP script to a save the contents of 4 text boxes to a SQl DB. Im currently using wamp.

[php]<?php
$Name = $_Post(‘Name’);
$Age = $_Post(‘Age’);
$Sex = $_Post(‘Sex’);
$Address_1 = $_Post(‘Address_1’);

mysql_connect(“localhost”,“Users”,"") or die ('Error: ’ .mysql_error());
mysql_select_db(“User”);

$query =“INSERT INTO users(Name,Age,Sex,Address_1) VALUES(”.$Name."’, ‘".$Age."’,’".$Sex."’,’".$Address_1."’)";

mysql_query($query) or die (‘Error updating datadase’);

?>[/php]

My question is what do i replace the “localhost” with ?.. iv tried the address of the database but it dosent seen to work.

thanks
TT

you should keep it as localhost or IP 127.0.0.1 just fill out the next 2 parts with your username and password

so it should like below

[php]mysql_connect(“localhost”,“Username”,“Password”) or die ('Error: ’ .mysql_error());[/php]

its a standard db connect script

hope this helps

Sponsor our Newsletter | Privacy Policy | Terms of Service