Jump to content

Problem connecting to database on wampserver


tosicky

Recommended Posts

I'm having problem connecting to database on wampserver.already i av set the username and password but each time i click on submit button it takes me to a blank page and the details entered on the form are not inserted in database. Any solution please

Edited by tosicky
Link to comment
Share on other sites

Here is the code. <?php $username="tosicky"; $password="physic"; $db="e-banking"; $host="localhost"; $cid=mysql_connect("localhost","tosicky","physic"); if (!cid){ echo("error:" .mysql_error()."\n");} ?> <? If ($_SERVER['REQUEST_METHOD'] == "POST") { $surname=$_POST['s_name']; $firstname=$_POST['f_name']; $sql="INSERT INTO registration"; $sql= $sql . "(s_name,f_name) VALUES"; $sql=$sql."('$surname','$firstname')"; $result=mysql_db_query($db,"$sql",$cid); if(!$result){ echo("error:" . mysql_error() . "\n$sql\n");} echo("new link added\n");} mysql_close($cid); ?>

Link to comment
Share on other sites

Have you started the WAMP server? (see their documentation)

Are you getting any errors output at all?

Is error reoprting set on? (use ini_set())

Echo the query you are using and use phpmyadmin (or equal) to see if the Query is working?

How are you confirming the lack of data in the DB?

Is "localhost" the server name?

 

Lots of things could be going wrong, but having those things checked will be a good start.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...