Jump to content

richard_PHP

Members
  • Posts

    79
  • Joined

  • Last visited

Everything posted by richard_PHP

  1. Thanks for the reply. I've looked at the source code and compared it with the PHP code and the only thing that is standing out which could be the cause is the IF statement itself. With a limited amount of knowledge in PHP I've tried to change it around as far as I can but nothing is working. Any further help/hints? Thanks EDIT: This is the source code around the problem area: <td class="dataTableContent" align="right" valign="top">£1.75</td> 6.00<td class="dataTableContent" valign="top" align="right">6</td> <td class="dataTableContent" align="right" valign="top">£10.50</td> </tr> <tr><td colspan="8"><hr /></td></tr>
  2. Hello all, After putting in a bit of short integer coding into what is an invoice page, the original string is echoed above where it should appear (see image). As indicated by the green arrow, the 6.00 is what showed up before the code was put in, the code addition now has the 'Qty' column displaying how I want, but has the '6.00' showing. I've had a look at the code and cannot find anything in the code which is causing this. Help much appreciated! Code: echo ' </td>' . "\n" . ' <td class="dataTableContent" align="right" valign="top">' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" . $num = $order->products[$i]["qty"]; if(intval($num) == $num){ $num = intval($num); } echo '<td class="dataTableContent" valign="top" align="right">' . $num . '</td>' . "\n" . ' <td class="dataTableContent" align="right" valign="top">' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n"; echo ' </tr>' . "\n"; }
  3. Hello all, I've recently made a post about intval, which was solved. However, the result now has the original values echoed out as well as the resulting shorter integers, which I don't want (see picture). http://imageshack.us/photo/my-images/405/problemsh.jpg Code here, not all code, but the one in question and all surrounding tags: ' <td class="dataTableContent" align="right" valign="top">' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" . $num = $order->products[$i]["qty"]; if(intval($num) == $num){ $num = intval($num); } echo '<td class="dataTableContent" valign="top" align="right">'.$num.'</td>' . "\n" . ' <td class="dataTableContent" align="right" valign="top">' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n"; Cheers,
  4. Unfortunately when I posted the previous message I found how to do it, so simple and I had a lapse.. you beat me to replying!!!! lol. Thanks again
  5. Thanks for that. I've looked into putting this into what I have, a downloaded shop system (OSCommerce) and can't find a way to do so. The part where I want the statement to validate is as follows: <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . '</td>' . "\n" .
  6. Hello all, I have a database which stores values as decimal and then a page which displays the info. I would like when it is a whole number (say 1.00, 2.00, 3.00 etc) to display without the decimals (1, 2, 3 etc) while leaving other numbers as is (1.5, 2.25, 3.08 etc). Cheers in advance!
  7. Hello all, Back again with yet another problem. I've got and upload to directory form and also an unlink form function all well and fine. However, on the viewing side I'm wanting the images uploaded using said forms to be displayed in their thumbnail form (eg- 1thumb.jpg) and then link to a larger version in their normal image size (eg- 1.jpg). So far I have the following code mustered up which displays the thumbnail. However, my query is how to link to the actual image it is for (so 1thumb.jpg links to 1.jpg, 2thumb.jpg links to 2.jpg, 3thumb.png leads to 3.png etc etc). Code: $directory = "portimg/"; $images = glob("" . $directory . "{*.jpg,*.gif,*.png}", GLOB_BRACE); $thumbs = glob("" . $directory . "{*thumb.jpg,*thumb.gif,*thumb.png}", GLOB_BRACE); //print each file name if (is_array($thumbs)) { foreach($thumbs as $thumb) { echo "<a href='" . $image . "'><img src='" . $thumb . "' /></a>"; } } else { echo "<p>No files present</p>"; } ?> Many thanks!!
  8. Brilliant! Many thanks for the help both of you
  9. In the previous page I have pulled the information from the database (id and imgurl) for use in this process. The above code uses the id number as choice and removes where they match. Could I just have the unlink as follows: $imgurl = $_POST[imgurl]; unlink($url); Cheers.
  10. Hello, I'm wanting to create a script which deletes an image from both a database and off the directory. I understand that the code needed to remove from the directory is UNLINK, I'm having trouble finding how to put it into my code. As follows: <?php $conn = mysql_pconnect("#####", "###", "####"); mysql_select_db("###", $conn); $choice = $_POST[choice]; mysql_query("DELETE FROM ## WHERE id='$choice'"); echo "<p>Image has been deleted.</p>"; echo "<p>Click <a href='adminphotos.php'>here</a> to delete another.</p>"; ?> So our user has selected with a radio button which image they would like to delete and this page processes that. At the moment the above code removes from the database. Thanks in advance!
  11. Nevermind! I've got it working! Thanks all anyway!
  12. FAO thara: Changed that but it's still not working FAO Pikachu2000: The webpage displays as normal but the YouTube embedded player (and thus video) don't show at all.
  13. Hello all, Using a database backend and the WHILE function I'm wanting all YouTube videos entered in said database to show up in one loop. Simples. However, coded it's deciding that it does not want to play ball. Code: <?php // Start the connection to the database $conn = mysql_pconnect("****", "******", "*****"); // Select the database to use mysql_select_db("*****", $conn); // Create the MySQL command to retrieve all records $sql = "SELECT * FROM videos"; $result = mysql_query($sql, $conn); while ($array = mysql_fetch_array($result)) { $title = $array[title]; $hlink = $array[hlink]; $desc = $array[description]; echo "<h2>$title</h2>"; echo "<iframe width='560' height='315' src='$hlink' frameborder='0' allowfullscreen></iframe>"; echo "<p>$desc</p><hr />"; } ?> The YouTube embed is in an echo line with the link to the video (eg: 'http://www.youtube.com/*****') in variable '$hlink'. I've tried \" instead of single quotes and it still isn't working. Hopefully someone can help. Thanks in advance
  14. Using the bog standard 'SELECT * FROM table' but it isn't selecting the first record in the database. Could someone show me where I'm going wrong? CODE: $conn = mysql_pconnect("****", "****", "****"); mysql_select_db("****", $conn); $sql = "SELECT * FROM testemonials"; $result = mysql_query($sql, $conn); $array = mysql_fetch_array($result); while ($array = mysql_fetch_array($result)) { $id = $array[id]; $quote = $array[quote]; $person = $array[person]; echo "<p><input name=choice type=radio value=$id /><br />$quote - $person</p>"; } Thanks all in advance!
  15. Worked it out! Simpler than I thought.
  16. Hello all, I have a contact form which has a drop-down-menu (the reason why a user is using the form). I am wanting the option which has been selected to appear in the PHP scripted email as the subject. I am just sat here staring at the code and getting nowhere with it. Could anyone help me? HTML form <form name="contact_form" method="post" action="mail.php" onsubmit="return validate_form();"> <p>Full Name <em>(required)</em>:<br /> <input class="tb-focus" type="text" name="name" id="name" size="40" value="" /></p> <p>Reason for Contact:<br /> <select class="select"> <option value="CV">CV Request</option> <option value="enquiry">General Enquiry</option> <option value="request">Request for Audition</option> </select> <p>Email Address <em>(required)</em>:<br /> <input class="tb-focus" type="text" name="email" id="email" size="40" value="" /></p> <p>Agency Name <em>(if applicable)</em>:<br /> <input class="tb-focus" type="text" name="business" id="business" size="40" value="" /></p> <p>Contact Number <em>(required)</em>:<br /> <input class="tb-focus" type="text" name="number" id="number" size="40" value="" /></p> <p>Message <em>(required)</em>:<br /> <textarea class="tb-focus" name="message" id="message" rows="6" cols="40"></textarea></p> <p><input class="button" type="submit" value="Submit Form" /></p> </form> PHP email POST: <?php // Assign the posted values as variables to use later $name = $_POST['name']; $email = $_POST['email']; $reason = $_POST['sdsdsd']; $business = $_POST['business']; $number = $_POST['number']; $message = $_POST['message']; $to = "*********"; $subject = "Email Contact Form - " . $_POST[name]; $message = "Filled out contact form on portfolio website.\n \n Full Name: " . $_POST[name] . "\n Email: " . $_POST[email] . "\n Business Name: " . $_POST[business] . "\n Contact Number: " . $_POST[number] . "\n Message: " . $_POST[message]; //leave the next 2 lines alone $headers .= "MIME-Version: 1.0rn"; $headers .= "Content-Type: text/html; charset=ISO-8859-1rn"; if (empty($name) || empty($email) || empty($number) || empty($message)) { echo "<p>You appear to not have filled in the necessary fields.</p>"; echo "<p>Please click <a href='contact.html'>here</a> to re-enter your information.</p>"; } elseif(!mail($to, $subject, $message, $headers)){ echo "Sorry, there has been an error! Please try sending your message again. Click <a href='contact.htm'>here</a> to start again."; } else { echo "Thank you for taking the time to fill out the contact form. I will get back to you as soon as I can."; } ?> I have absolutely no idea where to start with this. Thanks in advance for the help
  17. Soon as I read what you said I soon found what to do! It's the simple things.......... lol
  18. I have some code which deletes a record from my database (which has been selected from the previous page). Only problem is, it comes up with error code, but still deletes from the database? Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/110mb.com/t/h/e/b/l/a/c/k/theblackwatch/htdocs/150749deleted.php on line 28 Code: <?php $id = $_GET[id]; // Start the connection to the database $conn = mysql_pconnect("***", "***", "***"); // Select the database to use mysql_select_db("***", $conn); // Create the MySQL command to retrieve all records $sql = "DELETE FROM **** WHERE id ='$id'"; $result = mysql_query($sql, $conn); $array = mysql_fetch_array($result); // Echo each entry as the value of the text boxes. This brings in the current info in the database echo "<p>Entry has been deleted.</p>"; ?> Any way round it?
  19. Got it all working now. Thanks for all the help.
  20. I've tried inserting the example above (probably novice-like): <?php //Start the connection to the database $conn = mysql_connect("db4free.net", "rickscapepics", "nyjets16"); //Select the database to use mysql_select_db("scapepictures", $conn); // Create and run the MySQL command to retrieve the records $sql = "SELECT * DATE_FORMAT('date', '%D %M %Y') AS 'formatted_date' FROM blackwatch ORDER BY date ASC"; // Run the MySQL statement. Assign the results of the query to an array. Run a loop to repeat for each record in the table $now = time(); $result = mysql_query($sql, $conn); while ($array = mysql_fetch_array($result)) { $id = $array[id]; $date = $array[date]; $timestamp = strtotime($date); // convert to timestamp like what time() returns $location = $array[location]; if ($timestamp < $now) echo "<p class='past'>$date - $location</p>"; else echo "<p>$date - $location</p>"; } ?> And the website is saying 'Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in *****/events.php on line 30'
  21. Thanks for that link. I'm finding it hard to see where in my code I can implement it (bit of a novice). I'll want to use the specifiers: %D %M %Y
  22. Thanks. That's worked now. Is there a way for me to change the way the date looks? At the moment it is in the database (as a date attirbute) at YYYY-MM-DD, I would like it be either DD-MM-YYYY or even as long handed text (1st January 2011 etc)
  23. Hello all, I'm trying to make an events list where the date and location (info entered in a database) are shown, if the event has been and gone then the page display it in red itaclics. So far I have conjured up a basic bit of code but I'm having troubles gettin it to work! Help would be welcomed. Code: <?php // Start the connection to the database $conn = mysql_connect("d***", "r****s", "******"); // Select the database to use mysql_select_db("******", $conn); // Create and run the MySQL command to retrieve the records $sql = "SELECT * FROM *****h ORDER BY date ASCEN"; // Run the MySQL statement. Assign the results of the query to an array. Run a loop to repeat for each record in the table $now = time(); $result = mysql_query($sql, $conn); while ($array = mysql_fetch_array($result)) { $id = $array[id]; $date = $array[date]; $location = $array[location]; if ($date < $now) echo "<p class='past'>$date - $location</p>"; else echo "<p>$date - $location</p>"; } ?>
  24. Okay, after changing the code from the shockingly bad bit code having two opening <html> tags ( ), I now have the error message: Here's the code: <?php $name = trim($_POST['name']); $email = trim($_POST['email']); $business = trim($_POST['business']); $number = trim($_POST['number']); $message = trim($_POST['message']); $error = ''; if (isset($_POST['name']) && (empty($name) || empty($email) || empty($number) || empty($message))) { $error .= "<p>You appear to not have filled in the necessary fields.</p>"; } else { //validation passed, create and send the email $headers .= "MIME-Version: 1.0rn"; $headers .= "Content-Type: text/html; charset=ISO-8859-1rn"; mail($to, $subject, $message, $headers); //redirect to success page header('Location: mail.php'); exit(); } ?> <?php echo $error; ?> <form action=""> *Name: <input type="text" name="name" value="<?php echo $name; ?>" /><br> *Email: <input type="text" name="email" value="<?php echo $email; ?>" /><br> Business: <input type="text" name="business" value="<?php echo $business; ?>" /><br> *Number: <input type="text" name="number" value="<?php echo $number; ?>" /><br> *Message:<br /><textarea name="message"><?php echo $message; ?></textarea><br> <button type="submit">Send Email</button> </form>
  25. Thanks for the help. 'schilly', your code worked fine. 'mjdamato'...... I've tried your code and it has come up with: Warning: Cannot modify header information - headers already sent by (output started at ****htdocs/contact.php:7) in ******htdocs/contact.php on line 45. Any help? Line 45 contains: header('Location: mail.php');
×
×
  • 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.