Jump to content

Recommended Posts

hey where am i going wrong here? im new to databases and are confused on what ive done wrong ?

 

Tester 2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<form id="form1" name="form1" method="post" action="Tester1.php">

  <label>

  <input name="bandfield" type="text" id="bandfield" />

  </label>

  <label>

  <input type="submit" name="Submit" value="Submit" />

  </label>

</form>

 

 

</body>

</html>

 

Tester 1.php

<?php

 

$bandfield = $_POST['bandfield'];

 

$con = mysql_connect("localhost","","");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("", $con);

 

$result = mysql_query("SELECT * FROM Bands

WHERE bandname='$bandname'");

 

while($row = mysql_fetch_array($result))

  {

  echo $row['bandname'] . " " . $row['genre'];

  echo "<br />";

  }

?>

 

Very confused here help is much appreciated :D

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/162295-confused-when-doing-databases/
Share on other sites

That is the code

 

Tester1.php

<?php

 

$bandfield = $_POST['bandfield'];

 

$con = mysql_connect("localhost","myuklive_forum","615455");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("myuklive_Bands", $con);

 

$sql = "SELECT * FROM Bands WHERE bandname='$bandname'"

$result = mysql_query($sql ,$con) or die(mysql_error());

 

while($row = mysql_fetch_array($result))

  {

  echo $row['bandname'] . " " . $row['genre'];

  echo "<br />";

  }

?>

 

Tester2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<form id="form1" name="form1" method="post" action="Tester1.php">

  <label>

  <input name="bandfield" type="text" id="bandfield" />

  </label>

  <label>

  <input type="submit" name="Submit" value="Submit" />

  </label>

</form>

 

 

</body>

</html>

thanks yeh dont get an error anymore however results dont show up from the database?

 

just a blank white screen when typing in what im after ,

 

does the Tester2 Form send the "bandfield" across to the Tester2 form or have i done summit or need to put something into make it work?

 

cheers

Also you input tags inside labels

 

should be more like

 

<form id="form1" name="form1" method="post" action="Tester1.php">
  <label>PUT A LABEL HERE</label>
  <input name="bandfield" type="text" id="bandfield" />
  <input type="submit" name="Submit" value="Submit" />
</form>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.