Jump to content

JasonBruce88

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JasonBruce88's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you very much I will try this when I get back to work
  2. Again my explanation probably was not the best. What is not happing is the population of the select box options. I do appreciate your guys help even though I am not doing a good job of explaining it so thank you.
  3. Sorry, it was early in the morning. I meant show results not select results. Sorry for the miss leading question.
  4. Hello I am able to populate a select box with items form a mysql table no problem. But what I am creating is a form that repeats the fields depending on the users selection on the previous page. This works no problem except for the select box. It fails to select all the results. I have tried many combinations of nested loops but with no joy. In stead of posting all the code I will post the code which generates the select box. Any help or point in the right direction is very much welcome. echo "<fieldset>\n"; echo "<legend>\n"; echo "Products required for property\n"; echo "</legend>\n"; //echo $productItemLoop; $ProductIDArray = "ProductID$propNumber"; $ProductIDArrayBrackets = "[]"; while($nt1=mysql_fetch_array($result)){ $product_options_open = "<option value=\"$nt1[ProductID]\">"; $row_productType = $nt1['ProductType']; $product_options_close = "</option>\n"; } echo "<p>\n"; echo "Hold 'Ctrl' to select more than one product\n"; echo "<br />\n"; echo "<select multiple"; echo " "; echo "name="; echo "\"$ProductIDArray$ProductIDArrayBrackets\""; echo " "; echo "id=\"ProductID$propNumber\" size=\"5\">\n"; echo "$product_options_open\n"; echo "$row_productType\n"; echo "$product_options_close\n"; echo "</select>\n"; echo "</p>\n"; echo "</fieldset>\n";
  5. Hi I have hit a brick wall. Basically I am trying to create a system which will end up with something similar to gocompare.com etc, where a quote is generated from the results of previous pages. This is nearly all completed apart from one thing. On one of the previous pages where criteria is gathered for the quote they can select the products they need quotes on from a few check boxes, with the option to select more than one. My question is how can I add these multiple values from these selected check boxes to a cookie to use at a latter date. I have read in other places to store these in a databse which they will be, if the quote is saved or taken further. I just need to be able to take these values across to another page to be used again. Cheers
  6. I have a form that connects to a MySQL data base but for some reason when I submit the form, only pressing the button once, the data is added to the form twice? Anybody have any ideas on this? Here is the code HTML <?php include("inc/headerlogin.php"); ?> <form action="submited.php" method="post"> <fieldset> <legend>Customer details</legend> <p> <label for="FirstName">First name</label> <input type="text" name="FirstName" value="" id="FirstName"> </p> <p> <label for="LastName">Last name</label> <input type="text" name="LastName" value="" id="LastName"> </p> <p> <label for="Title">Title</label> <select name="Title" id="Title"> <option>Mr</option> <option>Mrs</option> <option>Miss</option> <option>Ms</option> <option>Dr</option> <option>Rev</option> <option>Sir</option> </select> </p> <p> <label for="PN1">Phone</label> <input type="text" name="PN1" value="" id="PN1"> <span>(primary)</span> </p> <p> <label for="PN2">Phone 2</label> <input type="text" name="PN2" value="" id="PN2"> <span>(secondary)</span> </p> <p> <label for="UserTypeCode">I am a:</label> <select name="UserTypeCode"> <option name="Landlord" value="1"> Landlord </option> <option name="Tenant" value="2"> Tenant </option> <option name="Engineer" value="3"> Engineer </option> </select> <p> <label for="Email">Email</label> <input type="text" name="Email" value="" id="Email"> </p> <p> <label for="Password">Password</label> <input type="Password" name="Password" value="" id="Password"> </p> <p> <label for="Password2">Password</label> <input type="Password" name="Password2" value="" id="Password2"> </p> <p class="alignright"> <input type="submit" name="submit" value="Confirm details" class="button"> </p> </fieldset> </form> <?php include("inc/footer.php"); ?> PHP: <?php include("inc/headerlogin.php"); $con = mysql_connect("*", "*", "*") or die(mysql_error("A MySQL error has occurred")); mysql_select_db("*") or die(mysql_error("A MySQL error has occurred")); if (!$con) { die('Could not connect: ' . mysql_error()); } if (isset($_POST['submit'])) { //ensures fields are not blank if (!$_POST['Email'] | !$_POST['Password'] | !$_POST['Password2']) { die('You did not complete all of the required fields'); } //Checks if email address is allready in use if (!get_magic_quotes_gpc()) { $_POST['Email'] = addslashes($_POST['Email']); } $emailcheck = $_POST['Email']; $chek = mysql_query("SELECT * FROM client WHERE Email = '$emailcheck'") or die(mysql_error()); $check2 = mysql_num_rows($chek); //notifys if email address is already registered if ($check2 != 0) { die('Sorry, the Email Address '.$_POST['Email'].' is already in use. Please try again'); } //makes sure passwords match if ($_POST['Password'] !=$_POST['Password2']) { die('The passwords you have entered do not match.Please try again'); } //encrypt the users password $_POST['Password'] = md5($_POST['Password']); if (!get_magic_quotes_gpc()) { $_POST['Password'] = addslashes($_POST['Password']); $_POST['Email'] = addslashes($_POST['Email']); } //insert into database $insert = "INSERT INTO client (FirstName, LastName, Title, PN1, PN2, Email, Password, UserTypeCode) VALUES ('".$_POST['FirstName']."', '".$_POST['LastName']."', '".$_POST['Title']."', '".$_POST['PN1']."', '".$_POST['PN2']."', '".$_POST['Email']."', '".$_POST['Password']."', '".$_POST['UserTypeCode']."')"; $add_member = mysql_query($insert); if (!mysql_query($insert,$con)) { die('Error: ' . mysql_error()); } echo "Thank you, you have registered - you may now login"; } mysql_close($con) ?>
  7. I do not have a link as it is only local the message i get through the browser is This page contains the following errors: error on line 7 at column 1: Extra content at the end of the document Below is a rendering of the page up to the first error. test test test tasha.jpg and the xml in the page source is <media> <fileName>test</fileName> <Artist>test</Artist> <Caption>test</Caption> <fileURL>tasha.jpg</fileURL> </media> <media> <fileName>Bad Romance</fileName> <Artist>Lady Gaga</Artist> <Caption>Bad Romance Clip</Caption> <fileURL>Badromance.mp3</fileURL> </media> <media> <fileName>Spider</fileName> <Artist>me</Artist> <Caption>A massive spider</Caption> <fileURL>07092009151.jpg</fileURL> </media> <media> <fileName>Jellyfish</fileName> <Artist>Jellyfish</Artist> <Caption>Jellyfish</Caption> <fileURL>Jellyfish.jpg</fileURL> </media> which is the right amount of values in the database
  8. Stupid mistake made on my behalf there <?php $con = mysql_connect("server", "user", "password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); if ($result = mysql_query ('SELECT * FROM media')) { if (mysql_num_rows($result)) { header ("Content-Type:text/xml"); echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; while ($row = mysql_fetch_array($result)) { echo "<media>\n"; echo"<fileName>" . $row['fileName'] . "</fileName>\n"; echo"<Artist>" . $row["Artist"] . "</Artist>\n"; echo"<Caption>" . $row["Caption"] . "</Caption>\n"; echo"<fileURL>" . $row["fileURL"] . "</fileURL>\n"; echo "</media>\n"; } } else { echo "Sorry, no records were found!"; } } else { trigger_error(mysql_error()); } ?> works kind of when looking at the page source all records are there, but only one is displayed on the page as i get an xml error error on line 8 at column 1: Extra content at the end of the document Line 8 on the php page returned from the server is when the next set of nodes begins again. does that mean there is a problem with where the XML decoration is placed, as it is also getting echoed at every loop??
  9. I have added what you have put into my code but it is not liking the second else statement as it is not expecting it but then when I put a brace in front of it does not expect that either $con = mysql_connect("server", "user", "password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("databse", $con); if ($result = mysql_query ('SELECT * FROM media')) { if (mysql_num_rows($result)) { echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; while ($row = mysql_fetch_array($result)); echo "<media>\n"; echo"<fileName>" . $row['fileName'] . "</fileName>\n"; echo"<Artist>" . $row["Artist"] . "</Artist>\n"; echo"<Caption>" . $row["Caption"] . "</Caption>\n"; echo"<fileURL>" . $row["fileURL"] . "</fileURL>\n"; echo "</media>\n"; } } else { echo "Sorry, no records were found!"; } else { trigger_error(mysql_error()); }
  10. Ah my bad here you go <?php $con = mysql_connect("server", "user", "password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("databse", $con); $result = mysql_query ('SELECT * FROM media')or die(mysql_error()); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; if ($row = mysql_fetch_array($result)) { while ($line = mysql_fetch_array($result)); echo "<media>\n"; echo"<fileName>" . $line['fileName'] . "</fileName>\n"; echo"<Artist>" . $line["Artist"] . "</Artist>\n"; echo"<Caption>" . $line["Caption"] . "</Caption>\n"; echo"<fileURL>" . $line["fileURL"] . "</fileURL>\n"; echo "</media>\n"; } ?>
  11. while ($line = mysql_fetch_array($result)); echo "<media>\n"; echo"<fileName>" . $line['fileName'] . "</fileName>\n"; echo"<Artist>" . $line["Artist"] . "</Artist>\n"; echo"<Caption>" . $line["Caption"] . "</Caption>\n"; echo"<fileURL>" . $line["fileURL"] . "</fileURL>\n"; echo "</media>\n"; and the page source returns <media> <fileName></fileName> <Artist></Artist> <Caption></Caption> <fileURL></fileURL> </media>
  12. Cheers for that, however now I just get a blank page and the page source is just one empty set of nodes
  13. Hi all I have a small issue its probably something simple but I have been looking at it for hours and am just going round in circles trying to fix it. I am relatively new to PHP, but do understand why I get most errors and what they mean. Any way the problem is I am mking a Flash CS4 movie that takes data from a MySQL data base using XML generated by PHP the code I am using is <?php $con = mysql_connect("server", "user", "password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_data_base", $con); $result = mysql_query ('SELECT * FROM media')or die(mysql_error()); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; if ($row = mysql_fetch_array($result)) { do{ ($line = mysql_fetch_array($result)); echo "<media>\n"; echo"<fileName>" . $line['fileName'] . "</fileName>\n"; echo"<Artist>" . $line["Artist"] . "</Artist>\n"; echo"<Caption>" . $line["Caption"] . "</Caption>\n"; echo"<fileURL>" . $line["fileURL"] . "</fileURL>\n"; echo "</media>\n"; }while($row = mysql_fetch_array($result)); } else {print "Sorry, no records were found!";} ?> The 3 errors that I get are 1. only one result is taken from the database there should be 3 as there are 3 rows of data in that table. 2. When I look at the page source in my browser It shows the first set of data in the right nodes, but then it has a second empty set of nodes. 3.When get/attempt Flash to use the XML data it says TypeError: Error #1088: The markup in the document following the root element must be well-formed. I believe that this though is simply because the PHP file is not working correctly. Any help on this will be a life saver thank you
×
×
  • 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.