Jump to content

Paul_Withers

Members
  • Posts

    72
  • Joined

  • Last visited

Everything posted by Paul_Withers

  1. <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to submit care guides"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; if (isset($_POST['listing_title'] ) ) { if( $_POST['listing_title'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['speciesCommon'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['business'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['postage_cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['multipostage'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['quantity'] == "" ) { echo "Error: Please go back and try again"; } else { $listing_title = mysqli_real_escape_string($con, $_POST['listing_title']); $speciesCommon = mysqli_real_escape_string($con, $_POST['speciesCommon']); $cost = mysqli_real_escape_string($con, $_POST['cost']); $business = mysqli_real_escape_string($con, $_POST['business']); $postage_cost = mysqli_real_escape_string($con, $_POST['postage_cost']); $multipostage = mysqli_real_escape_string($con, $_POST['multipostage'] ); $quantity = mysqli_real_escape_string($con, $_POST['quantity'] ); if( $multipostage == "per item" ) { $postage_cost = $quantity * $postage_cost; } elseif( $multipostage == "Combined Postage" ) { $postage_cost; } $total = $cost + $postage_costage; // Writes customer_sales information to the MySQL database $sqlCustomerSales = "INSERT INTO customer_sales(username, listing_title, speciesCommon, total, business, postage_cost, multipostage ) VALUES ( '". $username ."', '". $listing_title ."', '". $speciesCommon ."', '". $total ."', '". $business ."', '". $postage_cost ."', '". $multipostage."' )"; $result1 = mysqli_query($con, $sqlCustomerSales); // This writes the transaction to the MySQL database $memo = $listing_title; $datetime = date("Y-m-d H:i:s"); $regCustomerTransaction = "INSERT INTO customer_transactions(username, datetime, cost, postage_cost, memo) VALUES ( '". $username ."', '". $datetime ."', '". $cost ."', '". $postage_cost ."', '". $memo."' )"; // Query the database $result2 = mysqli_query($con, $regCustomerTransaction); } // This writes the user_stats to the MySQL database $total_items_sold = $quantity; $regUserStats = "INSERT INTO user_stats(username, datetime, total, items_listed, bonus_credits, last_credit_purchase, total_care_guides, total_items_sold, total_currently_listed_items, total_items_purchased, total_diary_entries, feedback ) VALUES ( '". $username ."', '". $datetime ."', '". $total ."', '". $quantity ."', '". $subtotal ."', '". $last_credit_purchase ."', '". $total_care_guides ."', '". $total_items_sold ."', '". $total_currently_listed_items ."', '". $total_items_purchased ."', '". $total_diary_entries ."', '". $feedback."' )"; // Query the database $result3 = mysqli_query($con, $regUserStats); } ?> <h1>Payment to <?php echo $username ?></h1><br> <strong>Thank you for confirming you would like to purchase <?php echo $speciesCommon ?> </strong> <br> <strong>Your payment comes to a total of <?php echo $total ?> </strong></h2> <br> <br> Please complete payment using the PayPal button <br> <br> <strong>NOTE: If you do not complete this purchase, the seller may report you and a strike will be marked on your account. <br> <br> Three strikes will mean your account will be suspended and you will not be able to register again.</strong><br> <br> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="shipping" value="<?php echo $postage_cost ?>"> <input type="hidden" name="business" value="<?php echo $business ?>"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="item_name" value="<?php echo $speciesCommon ?>"> <input type="hidden" name="amount" value="<?php echo $cost ?>"> <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="OnButton1(); OnButton2();" alt="PayPal – The safer, easier way to pay online." > <img alt="" align="center" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"></form> <?php } else { echo 'Sorry we were unable to process your listing. Please contact <a href="mailto:helpdesk@aquapetcentre.com?Subject=Listing%20error">helpdesk@aquapetcentre.com'; die(); include('includes/overall/footer.php'); } // Close the connection mysqli_close($con); ?>
  2. Changing it to echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="$username">'; echo '<input type="hidden" name="listing_title" value="$listing_title">'; echo '<input type="hidden" name="speciesCommon" value="$speciesCommon">'; echo '<input type="hidden" name="cost" value="$cost">'; echo '<input type="hidden" name="business" value="$business"'; echo '<input type="hidden" name="postage_cost" value="$postage_cost">'; echo '<input type="hidden" name="multipostage" value="$multipostage">'; echo '<li>Quantity:</li>'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo' <br>'; echo '</div>'; echo '<div align="center">'; echo '<br>'; echo '<input type="submit" value="Confirm Purchase"><br>'; echo '</form><br>'; doesnt work either
  3. Yes I know, I forgot to add the extra > in so the form should read echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>">'; echo '<input type="hidden" name="listing_title" value="<?php echo $listing_title ?>">'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>">'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>">'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>">'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>">'; echo "<ul class='results'>"; echo '<li>Quantity:</li>'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; but it still doesnt work
  4. Hi, I got this form which passes hidden values as well as a select menu. The only thing is, it doesnt seem to post the form data to the script. Here is the form echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="listing_title" value="<?php echo $listing_title ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo "<ul class='results'>"; echo '<li>Quantity:</li>'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo' </ul><br>'; echo '<div align="center">'; echo '<br>'; echo '<input type="submit" value="Confirm Purchase"><br>'; echo '</form><br>'; And here is the script that the form is posted to <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to submit care guides"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; if (isset($_POST['listing_title'], $_POST['speciesCommon'], $_POST['cost'], $_POST['business'], $_POST['postage_cost'], $_POST['multipostage'], $_POST['quantity'] ) ) { if( $_POST['listing_title'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['speciesCommon'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['business'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['postage_cost'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['multipostage'] == "" ) { echo "Error: Please go back and try again"; } elseif( $_POST['quantity'] == "" ) { echo "Error: Please go back and try again"; } else { $listing_title = mysqli_real_escape_string($con, $_POST['listing_title']); $speciesCommon = mysqli_real_escape_string($con, $_POST['speciesCommon']); $cost = mysqli_real_escape_string($con, $_POST['cost']); $business = mysqli_real_escape_string($con, $_POST['business']); $postage_cost = mysqli_real_escape_string($con, $_POST['postage_cost']); $multipostage = mysqli_real_escape_string($con, $_POST['multipostage'] ); $quantity = mysqli_real_escape_string($con, $_POST['quantity'] ); if( $multipostage == "per item" ) { $postage_cost = $quantity * $postage_cost; } elseif( $multipostage == "Combined Postage" ) { $postage_cost; } $total = $cost + $postage_costage; // Writes customer_sales information to the MySQL database $sqlCustomerSales = "INSERT INTO customer_sales(username, listing_title, speciesCommon, total, business, postage_cost, multipostage ) VALUES ( '". $username ."', '". $listing_title ."', '". $speciesCommon ."', '". $total ."', '". $business ."', '". $postage_cost ."', '". $multipostage."' )"; $result1 = mysqli_query($con, $sqlCustomerSales); // This writes the transaction to the MySQL database $memo = $listing_title; $datetime = date("Y-m-d H:i:s"); $regCustomerTransaction = "INSERT INTO customer_transactions(username, datetime, cost, postage_cost, memo) VALUES ( '". $username ."', '". $datetime ."', '". $cost ."', '". $postage_cost ."', '". $memo."' )"; // Query the database $result2 = mysqli_query($con, $regCustomerTransaction); } // This writes the user_stats to the MySQL database $total_items_sold = $quantity; $regUserStats = "INSERT INTO user_stats(username, datetime, total, items_listed, bonus_credits, last_credit_purchase, total_care_guides, total_items_sold, total_currently_listed_items, total_items_purchased, total_diary_entries, feedback ) VALUES ( '". $username ."', '". $datetime ."', '". $total ."', '". $quantity ."', '". $subtotal ."', '". $last_credit_purchase ."', '". $total_care_guides ."', '". $total_items_sold ."', '". $total_currently_listed_items ."', '". $total_items_purchased ."', '". $total_diary_entries ."', '". $feedback."' )"; // Query the database $result3 = mysqli_query($con, $regUserStats); } ?> <h1>Payment to <?php echo $username ?></h1><br> <?php echo '<strong>Thank you for confirming you would like to purchase $speciesCommon; </strong>'; echo '<br>'; echo '<strong>Your payment comes to a total of $total; </strong></h2>'; echo '<br>'; echo '<br>'; echo 'Please complete payment using the PayPal button<br>'; echo '<br>'; echo '<br>'; ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="shipping" value="<?php echo $postage_cost ?>"> <input type="hidden" name="business" value="<?php echo $business ?>"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="item_name" value="<?php echo $speciesCommon ?>"> <input type="hidden" name="amount" value="<?php echo $cost ?>"> <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="OnButton1(); OnButton2();" alt="PayPal – The safer, easier way to pay online." > <img alt="" align="center" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"></form> <?php } else { echo 'Sorry we were unable to process your listing. Please contact <a href="mailto:helpdesk@aquapetcentre.com?Subject=Listing%20error">helpdesk@aquapetcentre.com'; die(); include('includes/overall/footer.php'); } // Close the connection mysqli_close($con); ?> <h1>Payment to <?php echo $username ?></h1><br> works, but I think that is because it is passed in the SESSION. Any other $variable such as those below echo '<strong>Thank you for confirming you would like to purchase $speciesCommon; </strong>'; echo '<br>'; echo '<strong>Your payment comes to a total of $total; </strong></h2>'; does not work. Why is the form not posting the values to the database. Just in case it helps, the form gets its values from the database, and the values are displayed in the sales page on which the form is contained. Here is the page containing the form. <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to view this page!"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $business = $row['paypal_email']; $user_id = $_GET['user_id']; $results1 = $con->query("SELECT * FROM live_sales WHERE user_id = '$user_id';"); while($row = $results1->fetch_array()) { $username = $row['username']; $fishtype = $row['fishtype']; $speciesCommon = $row['speciesCommon']; $speciesScientific = $row['speciesScientific']; $listing_title = $row['listing_title']; $age = $row['age']; $quantity = $row['quantity']; $origin = $row['origin']; $size = $row['size']; $environment = $row['environment']; $waterChemistry = $row['waterChemistry']; $temperature = $row['temperature']; $feeding = $row['feeding']; $sexing = $row['sexing']; $compatability = $row['compatability']; $temperament = $row['temperament']; $breeding = $row['breeding']; $comments = $row['comments']; $postage_type = $row['postage_type']; $postage_cost = $row['postage_cost']; $multipostage = $row['multipostage']; $cost = $row['cost']; echo "<div class='result'>"; echo "<h3>$speciesCommon</h3>"; echo "<h2>$listing_title</h2>"; echo "<ul class='results'>"; echo "<li>Species</li>" . str_replace("_"," "," $fishtype") . "<br>"; echo "<li>Common Name:</li> $speciesCommon<br>"; echo "<li>Scientific Name:</li> $speciesScientific<br>"; echo "<li>Age:</li> $age<br>"; echo "<li>Quantity:</li> $quantity<br>"; echo "<li>Price per item:</li> £$cost<br>"; echo "<li>Origin:</li> $origin<br>"; echo "<li>Size:</li>$size<br>"; echo "<li>Environment:</li> $environment<br>"; echo "<li>Water Chemistry</li> $waterChemistry<br>"; echo "<li>Temperature:</li> $temperature<br>"; echo "<li>Feeding:</li> $feeding<br>"; echo "<li>Sexing:</li> $sexing<br>"; echo "<li>Compatability:</li> $compatability<br>"; echo "<li>Temperament:</li> $temperament<br>"; echo "<li>Breeding:</li>$breeding<br>"; echo "<li>Comments:</li> $comments<br>"; echo "<li>Postage Type:</li>$postage_type<br>"; echo "<li>Postage Cost:</li> £$postage_cost $multipostage<br>"; echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="listing_title" value="<?php echo $listing_title ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo "<ul class='results'>"; echo '<li>Quantity:</li>'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo' </ul><br>'; echo '<div align="center">'; echo '<br>'; echo '<input type="submit" value="Confirm Purchase"><br>'; echo '</form><br>'; echo '<br><br> </div>'; exit(); } } echo 'Sorry but we could not find any results.'; } include 'includes/overall/footer.php'; ?> Any help is always appreciated. aquaman
  5. I got a quick fix but dont know why it makes any difference echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<input type="" name="">'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo '<input type="submit" value="Confirm Purchase">'; echo '</form>'; adding echo '<input type="" name="">'; seem to have solved the problem. Why is this? Thanks aquaman
  6. Hi ginejm, I have had to change the way things work on my site. Now all I am doing is submitting hidden form items, and then a selection menu, the same as before. But for some reason, instead of echoing out the select menu, it is doing this Maximum of 10 available 1 2 3 4 etc. I rechecked the code you posted that was working, and cant see where I have gone wrong. Here is my form echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>"'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>"'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>"'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>"'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>"'; echo '<input type="hidden" name="business" value="<?php echo $business ?>"'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo '<input type="submit" name="submit" value="Confirm Purchase">'; echo '</form>'; I cant see where I have gone wrong. I have re read your post and I cannot see whats happened. Your help is much appreciated aquaman
  7. Hi ginerjm, I have made a change as I needed to forward the quantity along with some hidden form items to the payment page. But for some reason the code now reads Maximum of 10 available 1 2 3 4 etc but it is just echoing out the number and not in a select menu. Here is how i have used it in the form echo '<form action="regsale.php" method="POST">'; echo '<input type="hidden" name="username" value="<?php echo $username ?>'; echo '<input type="hidden" name="multipostage" value="<?php echo $multipostage ?>'; echo '<input type="hidden" name="speciesCommon" value="<?php echo $speciesCommon ?>'; echo '<input type="hidden" name="postage_cost" value="<?php echo $postage_cost ?>'; echo '<input type="hidden" name="cost" value="<?php echo $cost ?>'; echo '<input type="hidden" name="business" value="<?php echo $business ?>'; echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; echo '<input type="submit" name="submit" value="Confirm Purchase">'; echo '</form>'; I cant see where I have gone wrong. I have re read your post and I cannot see whats happened. Your help is much appreciated aquaman
  8. Hi, I have a page with a PayPal button at the bottom. I am attempting to run two actions when the PayPal button is pressed. One is to process the PayPal payment and the other that opens another page which I have called testpage.php I have used a script I found online as I have no experience in Javascript, this is meant to run two actions when the PayPal button is clicked. However only the testpage.php opens. Here is what i got, have I done it wrong? Or is there a better way to do this? <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; ?> <script language="Javascript"> <!-- function OnButton1() { document._xclick.action = "https://www.paypal.com/cgi-bin/webscr" // document._xclick.target = "_blank"; // Open in a new window document._xclick.submit(); // Submit the page return true; } function OnButton2() { document._xclick.action = "testpage.php" document._xclick.target = "_blank"; // Open in a new window // document._xclick.submit(); // Submit the page return true; } --> </script> <?php if (!isset($_SESSION['loggedin'])) { die("You must be logged in to view this page!"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $business = $row['paypal_email']; $user_id = $_GET['user_id']; $results1 = $con->query("SELECT * FROM live_sales WHERE user_id = '$user_id';"); while($row = $results1->fetch_array()) { $username = $row['username']; $fishtype = $row['fishtype']; $speciesCommon = $row['speciesCommon']; $speciesScientific = $row['speciesScientific']; $listing_title = $row['listing_title']; $age = $row['age']; $quantity = $row['quantity']; $origin = $row['origin']; $size = $row['size']; $environment = $row['environment']; $waterChemistry = $row['waterChemistry']; $temperature = $row['temperature']; $feeding = $row['feeding']; $sexing = $row['sexing']; $compatability = $row['compatability']; $temperament = $row['temperament']; $breeding = $row['breeding']; $comments = $row['comments']; $postage_type = $row['postage_type']; $postage_cost = $row['postage_cost']; $multipostage = $row['multipostage']; $cost = $row['cost']; echo "<div class='result'>"; echo "<h3>$speciesCommon</h3>"; echo "<h2>$listing_title</h2>"; echo "<ul class='results'>"; echo "<li>Species</li>" . str_replace("_"," "," $fishtype") . "<br>"; echo "<li>Common Name:</li> $speciesCommon<br>"; echo "<li>Scientific Name:</li> $speciesScientific<br>"; echo "<li>Age:</li> $age<br>"; echo "<li>Quantity:</li> $quantity<br>"; echo "<li>Price per item:</li> £$cost<br>"; echo "<li>Origin:</li> $origin<br>"; echo "<li>Size:</li>$size<br>"; echo "<li>Environment:</li> $environment<br>"; echo "<li>Water Chemistry</li> $waterChemistry<br>"; echo "<li>Temperature:</li> $temperature<br>"; echo "<li>Feeding:</li> $feeding<br>"; echo "<li>Sexing:</li> $sexing<br>"; echo "<li>Compatability:</li> $compatability<br>"; echo "<li>Temperament:</li> $temperament<br>"; echo "<li>Breeding:</li>$breeding<br>"; echo "<li>Comments:</li> $comments<br>"; echo "<li>Postage Type:</li>$postage_type<br>"; echo "<li>Postage Cost:</li> £$postage_cost $multipostage<br>"; ?> </ul> </div> <div align='center'> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <?php echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>'; if( $multipostage == "per item" ) { $postage_cost = $quantity * $postage_cost; } elseif( $multipostage == "Combined Postage" ) { $postage_cost; } ?> <br><br> <input type="hidden" name="shipping" value="<?php echo $postage_cost ?>"> <input type="hidden" name="business" value="<?php echo $business ?>"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="item_name" value="<?php echo $speciesCommon ?>"> <input type="hidden" name="amount" value="<?php echo $cost ?>"> <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="OnButton1(); OnButton2();" alt="PayPal – The safer, easier way to pay online." > <img alt="" align="center" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"></form> </div> <?php exit(); } } echo 'Sorry but we could not find any results.'; } include 'includes/overall/footer.php'; ?> Any help is always appreciated aquaman
  9. I never said I ran anything or implied I ran anything, I simply asked for some advice on something I was stuck on. How could I post ACTUAL code when the whole post started as a question, and my reply to Barand. Im sure I have said it before but arent forums places to ask for help??? Anyway Thank you for your solution, it was just what I was looking for. Many Thanks aquaman
  10. Hi Barand, thanks for your reply. Do you mean like this? Because the menu is empty <select name="quantity"> <option value="<?php echo $quantity ?>"><?php echo 'Maximum of ' . $quantity . ' available'?></option> <php for ($q=1; $q<=$quantity; $q++) { echo '<option value="$q">$q</option>'; } ?> </select> Thanks aquaman
  11. Hi, Im not sure whether this is a PHP or MySQL question, but im trying to get a select menu to only display the number of options that are defined in the mysql database. For example The code I have that retrieves the $quantity from the database. Lets say that $quantity = 3 Now I would like the option menu to only display three options, like this: <select name="quantity"> <option value="<?php echo $quantity ?>"><?php echo 'Maximum of ' . $quantity . ' available'?></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> but for example, if the $quantity was equal to 10 then I would like the menu to be displayed as such <select name="quantity"> <option value="<?php echo $quantity ?>"><?php echo 'Maximum of ' . $quantity . ' available'?></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> How is it possible to do this? I am completely at a loss here. Many Thanks aquaman
  12. Its ok I done it thank you Barand, and just for your information, I dont expect anybody to go through my code working out if statements, I was just staring at it and getting nowhere and my editor was not helping. So I thought I would post a question in a forum, I mean isnt that what they are for? Anyway, if anyone is interested, the code is <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to sell a item"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $email = $row['email']; $town = $row['town']; $county = $row['county']; $sql1="SELECT sum(amount) as amount FROM transaction WHERE posted_by = '$username'"; $result1 = mysqli_query($con, $sql1); while ($row = mysqli_fetch_assoc($result1)) { $credits = $row['amount']; if ($credits <= 0) { //not enough credits - show message and redirect echo "You have no remaining credits. You will be redirected to purchase more."; header( "Refresh:5; url=purchase.php", true, 303); exit(); } else { ?> <script type="text/javascript" src="jquery.js"></script> <form action="otherItemsCheck.php" id="sellForm" method="POST"> <input type="hidden" name="username" value="<?php echo $username ?>"></li> <input type="hidden" name="email" value="<?php echo $email ?>"></li> <input type="hidden" name="town" value="<?php echo $town ?>"></li> <input type="hidden" name="county" value="<?php echo $county ?>"></li> <h2>Sell your item</h2> <p><strong>A basic listing will cost 1 credit - extras will be added to the total cost of your listing</strong></p> <ul> <li>Category*:</br> <select name="category"> <option value="none">--choose--</option> <option value="air_pumps">Air Pumps</option> <option value="air_stones">Air Stones</option> <option value="aquariums">Aquariums</option> <option value="cleaning">Cleaning & Maintenance</option> <option value="equipment">CO2 Equipment</option> <option value="coral">Coral & Live Rock</option> <option value="decorations">Decorations</option> <option value="feeders">Feeders</option> <option value="filter_media">Filter Media & Accessories</option> <option value="food">Food</option> <option value="gravel">Gravel & Substrate</option> <option value="health_care">Health Care</option> <option value="heaters">Heaters & Chillers </option> <option value="lighting">Lighting & Hoods</option> <option value="meters">Meters & Controllers</option> <option value="deionization">Reverse Osmosis & Deionization </option> <option value="tubing">Tubing & Valves</option> <option value="uv">UV Steriliser Water Pumps</option> <option value="water_tests">Water Tests & Treatment</option> <option value="other">Other Fish & Aquarium</option> </select> </li> <li>Listing Title*:</br> <input type="text" name="listing_title"> <li><strong>Would you like your listing displayed in Bold?: <input type="checkbox" name="bold" value="1"/> 1 Credit</strong> </li> <li>Condition*:</br> <select name="item_condition"> <option>--choose--</option> <option value="New (Packaged)">New (Packaged)</option> <option value="New (None or damaged packaging">New (None or damaged packaging</option> <option value="Used - Working">Used - Working</option> <option value="Used - Not Working">Used - Not Working</option> </select> </li> <li>Brand*:</br> <select name="brand"> <option>Choose...</option> <option value="AI (Aqua Illumination)">AI (Aqua Illumination)</option> <option value="Algarde">Algarde</option> <option value="API">API</option> <option value="AquaEl">AquaEl</option> <option value="AquaGro">AquaGro</option> <option value="Aquamedic">Aquamedic</option> <option value="Aquarian">Aquarian</option> <option value="Aquarium Systems">Aquarium Systems</option> <option value="Aquatlantis">Aquatlantis</option> <option value="Arcadia">Arcadia</option> <option value="Azoo">Azoo</option> <option value="BiOrb/Reef One">BiOrb/Reef One</option> <option value="Blagdon">Blagdon</option> <option value="Boyu">Boyu</option> <option value="Classica">Classica</option> <option value="Cloverleaf">Cloverleaf</option> <option value="Deltec/D-D">Deltec/D-D</option> <option value="Dennerle">Dennerle</option> <option value="Eheim">Eheim</option> <option value="ESHa">ESHa</option> <option value="Hagen/Fluval">Hagen/Fluval</option> <option value="Hikari">Hikari</option> <option value="Hobby">Hobby</option> <option value="Hugo Kamishi">Hugo Kamishi</option> <option value="Interpet">Interpet </option> <option value="JMC">JMC</option> <option value="Juwel">Juwel</option> <option value="King British">King British</option> <option value="New Era">New Era</option> <option value="Nishikoi">Nishikoi</option> <option value="NT Labs">NT Labs</option> <option value="Oase">Oase</option> <option value="Ocean Nutrition">Ocean Nutrition</option> <option value="Penn Plax">Penn Plax</option> <option value="Pontec">Pontec</option> <option value="Red Sea">Red Sea</option> <option value="Rena">Rena</option> <option value="Salifert">Salifert</option> <option value="Seachem">Seachem</option> <option value="Seneye">Seneye</option> <option value="SuperFish">SuperFish</option> <option value="Tanktests">Tanktests</option> <option value="Tetra">Tetra</option> <option value="TMC">TMC</option> <option value="Tunze">Tunze</option> <option value="Two Little Fishies">Two Little Fishies</option> <option value="Waterlife">Waterlife</option> <option value="Wave Point">Wave Point</option> <option value="other">Other</option> </select> </li> <li>Model*:</br> <input type="text" name="model"> </li> <li>Colour*:</br> <select name="colour"> <option value="">--choose one--</option> <option value="White">White</option> <option value="Grey">Grey</option> <option value="Black">Black</option> <option value="Blue">Blue</option> <option value="Green">Green</option> <option value="Orange">Orange</option> <option value="Red">Red</option> <option value="Multicoloured">Multicoloured</option> <option value="Other">Other</option> </select> </li> <li>Quantity*:</br> <select name="quantity"> <option value="">--choose one--</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select><strong> 1 Credit entitles you to sell up to 10 of the same item. </strong> </li> <li>Price*:<br> <input type="text" name="price"> In UK Pound Sterling </li> <li>Description*:</br> <textarea name="comments"></textarea> </li> <li>Postage Type*:</br> <select name="postage_type"> <option>Choose...</option> <option disabled>Economy services</option> <option value="UK_CollectPlusTracked">Collect+ Economy Tracked (3 to 5 working days)</option> <option value="UK_HermesTracked">Hermes Tracked (3 to 5 working days)</option> <option value="UK_RoyalMailSecondClassStandard">Royal Mail 2nd Class (2 to 3 working days)</option> <option value="UK_RoyalMailSecondClassRecorded">Royal Mail 2nd Class Signed For (2 to 3 working days)</option> <option value="UK_RoyalMailTracked">Royal Mail Tracked 48 (2 to 3 working days)</option> <option value="UK_RoyalMail48">Royal Mail 48 (2 to 3 working days)</option> <option value="UK_OtherCourier3Days">Other Courier 3 days (3 working days)</option> <option value="UK_OtherCourier5Days">Other Courier 5 days (5 working days)</option> <option value="UK_OtherCourier">Other Courier (3 to 5 working days)</option> <option value="UK_SellersStandardRate">Other Courier 3-5 days (3 to 5 working days)</option> <option disabled>Standard services</option> <option value="UK_RoyalMailFirstClassStandard">Royal Mail 1st Class (1 working day)</option> <option value="UK_RoyalMailFirstClassRecorded">Royal Mail 1st Class Signed For (1 working day)</option> <option value="UK_RoyalMailNextDay">Royal Mail Tracked 24 (1 working day)</option> <option value="UK_RoyalMail24">Royal Mail 24 (1 working day)</option> <option value="UK_CollectPlusStandard">Collect+ Standard (2 working days)</option> <option value="UK_Parcelforce48">Parcelforce 48 (1 to 2 working days)</option> <option value="UK_OtherCourier48">Other 48 Hour Courier (1 to 2 working days)</option> <option disabled>Express services</option> <option value="UK_RoyalMailSpecialDeliveryNextDay">Royal Mail Special Delivery (TM) 1:00 pm (1 working day)</option> <option value="UK_RoyalMailSpecialDelivery9am">Royal Mail Special Delivery (TM) 9:00 am (1 working day)</option> <option value="UK_Parcelforce24">Parcelforce 24 (1 working day)</option> <option value="UK_OtherCourier24">Other 24 Hour Courier (1 working day)</option> <option disabled>Services from outside UK</option> <option value="UK_EconomyShippingFromOutside">Economy Delivery from outside UK (10 to 22 working days)</option> <option value="StandardDeliveryfromOutsideUKwithRoyalMail">Standard Delivery from outside UK with Royal Mail (7 to 13 working days)</option> <option value="UK_StandardShippingFromOutside">Standard Delivery from outside UK (4 to 10 working days)</option> <option value="UK_ExpeditedShippingFromOutside">Express Delivery from outside UK (1 to 3 working days)</option> <option value="UK_FedExIntlEconomy">FedEx International Economy (3 to 4 working days)</option> <option value="UK_TntIntlExp">TNT International Express (2 to 3 working days)</option> <option value="UK_TrackedDeliveryFromAbroad">Tracked delivery from outside UK (2 to 5 working days)</option> <option disabled>Collection</option> <option value="UK_CollectInPerson">Collection in Person </option> </select> </li> <li>Postage Cost*:</br> <input type="text" name="postage_cost"> </li> </ul> <ul> <li>Upload Photo:</br> <input id="text" type="text" name="upload_photo"> </li> <li><input type="checkbox" name="rotate" value="10"/><strong>For 10 credits, you can have your listing displayed on our homepage on a rotation basis. </strong> </li> <li> <input type="submit" value="List Item"></li> </ul> </form> <script type="text/javascript" src="saleSpecies.js"></script> <?php include 'includes/overall/footer.php'; } } } }?> Thanks aquaman
  13. Nope it is a } not a ) and "it says this } here" <?php } include 'includes/overall/footer.php'; ?> as in the } after <?php at the foot of the file. Error is on line 269 as stated in my first post Parse error: syntax error, unexpected end of file in /Applications/XAMPP/xamppfiles/htdocs/other_items.php on line 269 I know there are closing } missing but I cannot work out where to put the, without my text editor saying the } is unmatched. I dont know how to put this any clearer. Thanks aquaman
  14. Hi, I got this form, but I dont want the form to be displayed if the user has run out of credits. The page worked until I added the credit check and now I get this error Parse error: syntax error, unexpected end of file in /Applications/XAMPP/xamppfiles/htdocs/other_items.php on line 269 I know this is because some } are missing, but whenever I move them about, it either doesnt work, or says there is no { to match the } with. Im really confused now and got another 2 pages to do this to, so really need to sort this one out. Here is what I got <?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to sell a item"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $email = $row['email']; $town = $row['town']; $county = $row['county']; } } // THIS IS NEW // CHECK WHETHER USER HAS CREDITS REMAINING $query = "SELECT SUM(amount) FROM transaction WHERE username = $username"; $result = mysqli_query($con, $query); if($result) { $row = mysqli_fetch_row($result); $amount = $row['amount']; if ( ($amount) <= 0) { //not enough credits - show message and redirect echo "You either have no remaining credits or not enough to complete this transaction. You will be redirected to purchase more."; header( "Refresh:5; url=purchase.php", true, 303); exit(); } else { // UP TO HERE ?> <script type="text/javascript" src="jquery.js"></script> <form action="otherItemsCheck.php" id="sellForm" method="POST"> <input type="hidden" name="username" value="<?php echo $username ?>"></li> <input type="hidden" name="email" value="<?php echo $email ?>"></li> <input type="hidden" name="town" value="<?php echo $town ?>"></li> <input type="hidden" name="county" value="<?php echo $county ?>"></li> <h2>Sell your item</h2> <p><strong>A basic listing will cost 1 credit - extras will be added to the total cost of your listing</strong></p> <ul> <li>Category*:</br> <select name="category"> <option value="none">--choose--</option> <option value="air_pumps">Air Pumps</option> <option value="air_stones">Air Stones</option> <option value="aquariums">Aquariums</option> <option value="cleaning">Cleaning & Maintenance</option> <option value="equipment">CO2 Equipment</option> <option value="coral">Coral & Live Rock</option> <option value="decorations">Decorations</option> <option value="feeders">Feeders</option> <option value="filter_media">Filter Media & Accessories</option> <option value="food">Food</option> <option value="gravel">Gravel & Substrate</option> <option value="health_care">Health Care</option> <option value="heaters">Heaters & Chillers </option> <option value="lighting">Lighting & Hoods</option> <option value="meters">Meters & Controllers</option> <option value="deionization">Reverse Osmosis & Deionization </option> <option value="tubing">Tubing & Valves</option> <option value="uv">UV Steriliser Water Pumps</option> <option value="water_tests">Water Tests & Treatment</option> <option value="other">Other Fish & Aquarium</option> </select> </li> <li>Listing Title*:</br> <input type="text" name="listing_title"> <li><strong>Would you like your listing displayed in Bold?: <input type="checkbox" name="bold" value="1"/> 1 Credit</strong> </li> <li>Condition*:</br> <select name="item_condition"> <option>--choose--</option> <option value="New (Packaged)">New (Packaged)</option> <option value="New (None or damaged packaging">New (None or damaged packaging</option> <option value="Used - Working">Used - Working</option> <option value="Used - Not Working">Used - Not Working</option> </select> </li> <li>Brand*:</br> <select name="brand"> <option>Choose...</option> <option value="AI (Aqua Illumination)">AI (Aqua Illumination)</option> <option value="Algarde">Algarde</option> <option value="API">API</option> <option value="AquaEl">AquaEl</option> <option value="AquaGro">AquaGro</option> <option value="Aquamedic">Aquamedic</option> <option value="Aquarian">Aquarian</option> <option value="Aquarium Systems">Aquarium Systems</option> <option value="Aquatlantis">Aquatlantis</option> <option value="Arcadia">Arcadia</option> <option value="Azoo">Azoo</option> <option value="BiOrb/Reef One">BiOrb/Reef One</option> <option value="Blagdon">Blagdon</option> <option value="Boyu">Boyu</option> <option value="Classica">Classica</option> <option value="Cloverleaf">Cloverleaf</option> <option value="Deltec/D-D">Deltec/D-D</option> <option value="Dennerle">Dennerle</option> <option value="Eheim">Eheim</option> <option value="ESHa">ESHa</option> <option value="Hagen/Fluval">Hagen/Fluval</option> <option value="Hikari">Hikari</option> <option value="Hobby">Hobby</option> <option value="Hugo Kamishi">Hugo Kamishi</option> <option value="Interpet">Interpet </option> <option value="JMC">JMC</option> <option value="Juwel">Juwel</option> <option value="King British">King British</option> <option value="New Era">New Era</option> <option value="Nishikoi">Nishikoi</option> <option value="NT Labs">NT Labs</option> <option value="Oase">Oase</option> <option value="Ocean Nutrition">Ocean Nutrition</option> <option value="Penn Plax">Penn Plax</option> <option value="Pontec">Pontec</option> <option value="Red Sea">Red Sea</option> <option value="Rena">Rena</option> <option value="Salifert">Salifert</option> <option value="Seachem">Seachem</option> <option value="Seneye">Seneye</option> <option value="SuperFish">SuperFish</option> <option value="Tanktests">Tanktests</option> <option value="Tetra">Tetra</option> <option value="TMC">TMC</option> <option value="Tunze">Tunze</option> <option value="Two Little Fishies">Two Little Fishies</option> <option value="Waterlife">Waterlife</option> <option value="Wave Point">Wave Point</option> <option value="other">Other</option> </select> </li> <li>Model*:</br> <input type="text" name="model"> </li> <li>Colour*:</br> <select name="colour"> <option value="">--choose one--</option> <option value="White">White</option> <option value="Grey">Grey</option> <option value="Black">Black</option> <option value="Blue">Blue</option> <option value="Green">Green</option> <option value="Orange">Orange</option> <option value="Red">Red</option> <option value="Multicoloured">Multicoloured</option> <option value="Other">Other</option> </select> </li> <li>Quantity*:</br> <select name="quantity"> <option value="">--choose one--</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select><strong> 1 Credit entitles you to sell up to 10 of the same item. </strong> </li> <li>Price*:<br> <input type="text" name="price"> In UK Pound Sterling </li> <li>Description*:</br> <textarea name="comments"></textarea> </li> <li>Postage Type*:</br> <select name="postage_type"> <option>Choose...</option> <option disabled>Economy services</option> <option value="UK_CollectPlusTracked">Collect+ Economy Tracked (3 to 5 working days)</option> <option value="UK_HermesTracked">Hermes Tracked (3 to 5 working days)</option> <option value="UK_RoyalMailSecondClassStandard">Royal Mail 2nd Class (2 to 3 working days)</option> <option value="UK_RoyalMailSecondClassRecorded">Royal Mail 2nd Class Signed For (2 to 3 working days)</option> <option value="UK_RoyalMailTracked">Royal Mail Tracked 48 (2 to 3 working days)</option> <option value="UK_RoyalMail48">Royal Mail 48 (2 to 3 working days)</option> <option value="UK_OtherCourier3Days">Other Courier 3 days (3 working days)</option> <option value="UK_OtherCourier5Days">Other Courier 5 days (5 working days)</option> <option value="UK_OtherCourier">Other Courier (3 to 5 working days)</option> <option value="UK_SellersStandardRate">Other Courier 3-5 days (3 to 5 working days)</option> <option disabled>Standard services</option> <option value="UK_RoyalMailFirstClassStandard">Royal Mail 1st Class (1 working day)</option> <option value="UK_RoyalMailFirstClassRecorded">Royal Mail 1st Class Signed For (1 working day)</option> <option value="UK_RoyalMailNextDay">Royal Mail Tracked 24 (1 working day)</option> <option value="UK_RoyalMail24">Royal Mail 24 (1 working day)</option> <option value="UK_CollectPlusStandard">Collect+ Standard (2 working days)</option> <option value="UK_Parcelforce48">Parcelforce 48 (1 to 2 working days)</option> <option value="UK_OtherCourier48">Other 48 Hour Courier (1 to 2 working days)</option> <option disabled>Express services</option> <option value="UK_RoyalMailSpecialDeliveryNextDay">Royal Mail Special Delivery (TM) 1:00 pm (1 working day)</option> <option value="UK_RoyalMailSpecialDelivery9am">Royal Mail Special Delivery (TM) 9:00 am (1 working day)</option> <option value="UK_Parcelforce24">Parcelforce 24 (1 working day)</option> <option value="UK_OtherCourier24">Other 24 Hour Courier (1 working day)</option> <option disabled>Services from outside UK</option> <option value="UK_EconomyShippingFromOutside">Economy Delivery from outside UK (10 to 22 working days)</option> <option value="StandardDeliveryfromOutsideUKwithRoyalMail">Standard Delivery from outside UK with Royal Mail (7 to 13 working days)</option> <option value="UK_StandardShippingFromOutside">Standard Delivery from outside UK (4 to 10 working days)</option> <option value="UK_ExpeditedShippingFromOutside">Express Delivery from outside UK (1 to 3 working days)</option> <option value="UK_FedExIntlEconomy">FedEx International Economy (3 to 4 working days)</option> <option value="UK_TntIntlExp">TNT International Express (2 to 3 working days)</option> <option value="UK_TrackedDeliveryFromAbroad">Tracked delivery from outside UK (2 to 5 working days)</option> <option disabled>Collection</option> <option value="UK_CollectInPerson">Collection in Person </option> </select> </li> <li>Postage Cost*:</br> <input type="text" name="postage_cost"> </li> </ul> <ul> <li>Upload Photo:</br> <input id="text" type="text" name="upload_photo"> </li> <li><input type="checkbox" name="rotate" value="10"/><strong>For 10 credits, you can have your listing displayed on our homepage on a rotation basis. </strong> </li> <li> <input type="submit" value="List Item"></li> </ul> </form> <script type="text/javascript" src="saleSpecies.js"></script> <?php } include 'includes/overall/footer.php'; ?> eg, it says this } here: <?php } include 'includes/overall/footer.php'; ?> Is unmatched. I know whats wrong, just not how to fix it Any help is always much appreciated. aquaman
  15. Hi Barand, thanks for your answer, it works great now.
  16. Hi Barand, Have tried this $query = "SELECT user_id, listing_title FROM live_sales WHERE CONCAT_WS(' ', user_id, listing_title, fishtype, speciesCommon, speciesScientific, town, county) LIKE '%$e%'"; But this results in the same result being repeated twice
  17. Hi mac_gyver, yes that did work, thank you Now I have another search to search for items for sale. I have this working, with the $user_id being the result. But I don't want this to be displayed in the results, I would like the $aquaticCenterName to be displayed instead. ($user_id is going to be changed to id as it has nothing to do with the user). Here is what I got so far <?php include 'init.php'; // normal search $result_tb = ""; if (!empty($_POST['SEARCH']) && !empty($_POST['search_value'])) { $e = $_POST['search_value']; $query = "SELECT user_id FROM live_sales WHERE CONCAT_WS(' ', user_id, listing_title, fishtype, speciesCommon, speciesScientific, town, county) LIKE '%$e%'"; $query_result = $con->query($query); $result_tb = '<div><h2>Search Results:</h2>'; while ($rows = $query_result->fetch_assoc()) { foreach ($rows as $k => $v) { $u = $rows['user_id']; $v = urlencode($u); // since this is a text name, make it url encoded $result_tb .= "<a href='searchResultslive.php?user_id=$v'>$u</a><br>"; } } $result_tb .='</div>'; $con->close(); } ?> <?php include 'includes/overall/header.php'; include 'includes/logo.php'; ?> <h1>Search Species for Sale</h1> <p>Search for the aquatic species of your choice.</p> <p> You can search for your item via species type, name, scientific name, town or county.</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td> <input type="text" name="search_value" size="40" maxlength="40" value="Search for species"/> </td> <td> <input type="submit" name="SEARCH" value="Search"/> </td> </tr> </table> </form> <?php echo $result_tb; ?> <?php include 'includes/overall/footer.php'; So ideally the results would show the Aquatic Center Name, but the link would be results.php?user_id=2 ? Many Thanks aquaman
  18. Hi mac_gyver, thanks for your reply. That all works great, apart from when the resulting aquatic center contains a + in between the words eg. http://localhost/reviewResults.php?aquaticCenterName=Lissies+Aquatics But I wont be able to retrieve information from the database with the + being there. Is it possible to remove this? Many Thanks aquaman
  19. Hi, thanks for your reply. Error checking is on and no errors are reported. Here is the echoed query SELECT aquaticCenterName FROM reviews WHERE aquaticCenterName LIKE '%Chelmsford%' OR town LIKE '%Chelmsford%' OR county LIKE '%Chelmsford%' OR country LIKE '%Chelmsford%' OR rating LIKE '%Chelmsford%' And here is the echoed $v Lissies Aquatics This is the result of the query. I just cant get the value of $v to work in a link
  20. Hi and thanks for your reply. I made the change as suggested, but now when I search, I do not get any results. Here is the code now <?php include 'init.php'; // normal search $result_tb = ""; if (!empty($_POST['SEARCH']) && !empty($_POST['search_value'])) { $e = $_POST['search_value']; $query = 'SELECT aquaticCenterName FROM reviews WHERE ' . "aquaticCenterName LIKE '%$e%' OR " . "town LIKE '%$e%' OR " . "county LIKE '%$e%' OR " . "country LIKE '%$e%' OR " . "rating LIKE '%$e%' "; $query_result = $con->query($query); $result_tb = '<div>'; while ($rows = $query_result->fetch_assoc()) { $v = $rows['aquaticCenterName']; $result_tb .= "<a href='reviewResults.php?aquaticCenterName=$v>$v</a><br>"; } } $result_tb .='</div><hr>'; $con->close(); ?> <?php include 'includes/overall/header.php'; include 'includes/logo.php'; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td> <input type="text" name="search_value" size="30" maxlength="30"/> </td> <td> <input type="submit" name="SEARCH" value="Search"/> </td> </tr> </table> </form> <?php echo $result_tb; ?> <?php include 'includes/overall/footer.php';
  21. I have tried changing it to $result_tb .= '<a href="reviewResults.php?aquaticCenterName='$v'">' . $v . '</a><br>'; but I get this error Parse error: syntax error, unexpected '$v' (T_VARIABLE) in /Applications/XAMPP/xamppfiles/htdocs/reviews.php on line 23 How do I get the value of $v into the link?
  22. Hi, I have a script which searches the MySQL database. It outputs the result which is a business name, but I need the business name to be in a link so the user can click on it and go to another page to find out more information. However the business name is not included in the link, but the $value is. Here is my script <?php include 'init.php'; // normal search $result_tb = ""; if (!empty($_POST['SEARCH']) && !empty($_POST['search_value'])) { $e = $_POST['search_value']; $query = 'SELECT aquaticCenterName FROM reviews WHERE ' . "aquaticCenterName LIKE '%$e%' OR " . "town LIKE '%$e%' OR " . "county LIKE '%$e%' OR " . "country LIKE '%$e%' OR " . "rating LIKE '%$e%' "; $query_result = $con->query($query); $result_tb = '<div>'; while ($rows = $query_result->fetch_assoc()) { foreach ($rows as $k => $v) { $result_tb .= '<a href="reviewResults.php?aquaticCenterName= . $v . ">' . $v . '</a><br>'; } } $result_tb .='</div><hr>'; $con->close(); } ?> <?php include 'includes/overall/header.php'; include 'includes/logo.php'; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td> <input type="text" name="search_value" size="30" maxlength="30"/> </td> <td> <input type="submit" name="SEARCH" value="Search"/> </td> </tr> </table> </form> <?php echo $result_tb; ?> <?php include 'includes/overall/footer.php'; But when I click on the link, I get this in the address bar reviewResults.php?aquaticCenterName=%20.%20$v%20. How do I get this to read eg, reviewResults.php?aquaticCenterName=PaulsAquaticCenter Many Thanks aquaman
  23. Hi Barana, thanks for that, I didnt notice lol. My error, i had mispelt compatibility and compatability Doh!
  24. Ok got: <?php session_start(); error_reporting(E_ALL); ini_set('display_errors', '1'); require( 'database.php' ); include('includes/overall/header.php'); $username = $_SESSION['loggedinuser']; if(isset($_POST['username'], $_POST['email'], $_POST['fishtype'], $_POST['speciesCommon'], $_POST['speciesScientific'], $_POST['speciesSynonym'], $_POST['origin'], $_POST['size'], $_POST['environment'], $_POST['waterChemistry'], $_POST['temperature'], $_POST['temperature1'], $_POST['feeding'], $_POST['sexing'], $_POST['compatability'], $_POST['temperament'], $_POST['breeding'], $_POST['comments'], $_POST['reward'])) { echo '<pre>'.print_r($_POST,true).'</pre>'; // here if( $_POST['fishtype'] == "" ) { include('includes/overall/header.php'); echo "You must select a species type"; include('includes/overall/footer.php'); } elseif( $_POST['speciesCommon'] == "" ) { include('includes/overall/header.php'); echo "You must select a species type"; include('includes/overall/footer.php'); } elseif( $_POST['speciesScientific'] == "" ) { include('includes/overall/header.php'); echo "You must select a scientific name"; include('includes/overall/footer.php'); } elseif( $_POST['speciesSynonym'] == "" ) { include('includes/overall/header.php'); echo "You must select a species synonym"; include('includes/overall/footer.php'); } elseif( $_POST['origin'] == "" ) { include('includes/overall/header.php'); echo "You must select the origin of this species"; include('includes/overall/footer.php'); } elseif( $_POST['size'] == "" ) { include('includes/overall/header.php'); echo "You must select a average size"; include('includes/overall/footer.php'); } elseif( $_POST['environment'] == "" ) { include('includes/overall/header.php'); echo "You must select the type of environment suited to this species"; include('includes/overall/footer.php'); } elseif( $_POST['waterChemistry'] == "" ) { include('includes/overall/header.php'); echo "You must select the typeif water chemistry required for this species"; include('includes/overall/footer.php'); } elseif( $_POST['temperature'] == "" ) { include('includes/overall/header.php'); echo "You must select a minimum temperature for this species"; include('includes/overall/footer.php'); } elseif( $_POST['temperature1'] == "" ) { include('includes/overall/header.php'); echo "You must select a maximum temperature for this species"; include('includes/overall/footer.php'); } elseif( $_POST['temperament'] == "" ) { include('includes/overall/header.php'); echo "You must enter temperament information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['feeding'] == "" ) { include('includes/overall/header.php'); echo "You must enter feeding information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['sexing'] == "" ) { include('includes/overall/header.php'); echo "You must enter sexing information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['compatibility'] == "" ) { include('includes/overall/header.php'); echo "You must enter compatibility information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['breeding'] == "" ) { include('includes/overall/header.php'); echo "You must enter breeding information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['comments'] == "" ) { include('includes/overall/header.php'); echo "You must enter comments for this species"; include('includes/overall/footer.php'); } elseif( $_POST['compatibility'] == "" ) { include('includes/overall/header.php'); echo "You must select your reward"; include('includes/overall/footer.php'); } else { echo 'call'; exit; $fishtype = mysqli_real_escape_string($con, $_POST['fishtype']); $speciesCommon = mysqli_real_escape_string($con, $_POST['speciesCommon']); $speciesScientific = mysqli_real_escape_string($con, $_POST['speciesScientific']); $speciesSynonym = mysqli_real_escape_string($con, $_POST['speciesSynonym'] ); $origin = mysqli_real_escape_string($con, $_POST['origin']); $size = mysqli_real_escape_string($con, $_POST['size']); $environment = mysqli_real_escape_string($con, $_POST['environment']); $waterChemistry = mysqli_real_escape_string($con, $_POST['waterChemistry']); $temperature = mysqli_real_escape_string($con, $_POST['temperature']); $temperature1 = mysqli_real_escape_string($con, $_POST['temperature1']); $feeding = mysqli_real_escape_string($con, $_POST['feeding']); $sexing = mysqli_real_escape_string($con, $_POST['sexing']); $compatibility = mysqli_real_escape_string($con, $_POST['compatibility']); $temperament = mysqli_real_escape_string($con, $_POST['temperament']); $breeding = mysqli_real_escape_string($con, $_POST['breeding']); $comments = mysqli_real_escape_string($con, $_POST['comments']); $reward = mysqli_real_escape_string($con, $_POST['reward']); $username = mysqli_real_escape_string($con, $_POST['username']); $email = mysqli_real_escape_string($con, $_POST['email']); // Define a query to run $regCareGuide = "INSERT INTO species( fishtype, speciesCommon, speciesScientific, speciesSynonym, origin, size, environment, waterChemistry, temperature, temperature1, temperament, feeding, sexing, compatibility, breeding, comments, username, email ) VALUES ( '". $fishtype ."', '". $speciesCommon ."', '". $speciesScientific ."', '". $speciesSynonym ."', '". $origin ."', '". $size ."', '". $environment ."', '". $waterChemistry ."', '". $temperature ."', '". $temperature1 ."', '". $temperament ."', '". $feeding ."', '". $sexing ."', '". $compatability ."', '". $breeding ."', '". $comments ."', '". $reward ."', '". $username ."', '". $email."' )"; // Query the database $result = mysqli_query($con, $regCareGuide); // Check if the query failed if( !$result ) { die('There was a problem executing the query ('.$regCareGuide.'):<br>('.mysqli_errno($con).') '.mysqli_error($con)); } else { echo 'Your care guide has been submitted and your account credited.'; } } include('includes/overall/footer.php'); } // Close the connection mysqli_close($con); ?> But no luck???
×
×
  • 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.