Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. I personally wouldn't be interested in finding out why it's doing it, I'd be concentrating on creating file names that don't contain apostrophes in the first place. Maybe run [code=php:0]$_FILES['uploadFile']['name'][/code] through some checks first to make sure that it contains only alpha-numeric characters before renaming the file to it. Regards Huggie
  2. With regards to the unique name, that's simple, you have the code already.  Instead of calling it the same name as the original file, just use the unique name. [code]<?php move_uploaded_file($_FILES['filename']['tmp_name'], "../$source/".$unique_id); ?>[/code] Regards Huggie
  3. A regular expression and count would get you the result you're after... [code]<?php $string = "123.456.789"; $pattern = "/(\.)/"; if (preg_match_all($pattern, $string, $matches)){   echo $string . " has " .count($matches[1]). " . in it"; } else {   echo $string . " has 0 . in it"; } ?>[/code] Regards Huggie
  4. OK, you'll be able to get rid of the first three errors by changing the sql query.  Look at the first error: [quote] Notice: Query failed: Unknown column 'x051' in 'where clause' SQL: SELECT itemPrice FROM products WHERE itemId = x051 [/quote] This can be corrected by adding single quotes to the query [color=blue]SELECT itemPrice FROM products WHERE itemId = [color=red]'[/color]x051[color=red]'[/color][/color] This will also remove the second two errors as they're only occurring because the query is failing. Regards Huggie
  5. There is a way, and I believe you need to use the IMAP protocol.  There's some information about it [url=http://uk.php.net/manual/en/function.mail.php]here[/url]. Regards Huggie
  6. My advice would be to get php to send the mail as suggested already. PHP's [url=http://uk.php.net/manual/en/function.mail.php]mail()[/url] function is extremely easy to use and it's very effective.  I'm sure It'll be able to do everything that your current CGI script does. Regards Huggie
  7. You need to use fopen() in conjunction with fwrite(). My advice would be to join the path first, not in the function, so like this: [code]<?php $file = $_SESSION['username'] . "/" . $_POST['name']; if ($fh = fopen($file, "w"){   fwrite($fh, "This is test text\n"); } else {   echo "Couldn't create file\n"; } ?>[/code] Regards Huggie
  8. Or better still, use a foreach loop and save yourself some trouble. Regards Huggie
  9. In that case, you should know what this is doing: [code=php:0]<?php virtual('/nimatest/Connections/nimatest.php'); ?>[/code] Regards Huggie
  10. I don't know anything about loading csv files into MySQL, hence the other approach I suggested.  I can't help if you go down this route, sorry. Huggie
  11. Just put the whole WHERE clause into an if statement... [code]<?php $sql = "SELECT * FROM fruitstands"; if (isset($_POST['qfruit']) && ($_POST['qfruit'] != "Please select a fruit..."){   $sql .= " WHERE fruit = '".$_POST['qfruit']."'"; }[/code] Regards Huggie
  12. Sure... [code=php:0]UPDATE table_name SET col1 = 'value1', col2 = 'value2', col3 = 'value3' WHERE condition = 'something'[/code] Regards Huggie
  13. Try [url=http://uk.php.net/manual/en/function.array-reverse.php]array_reverse()[/url]. Regards Huggie
  14. Yes, that's correct. Don't forget to use the new 'Solved' button to mark this topic as solved. Regards Huggie
  15. OK, first of all you're going to need to setup your webserver to serve a custom php file instead of a default 404 message.  Have you done this or can you do this? Regards Huggie
  16. You have the wrong variable name.  Change this... [code=php:0]$result = mysql_query($sql) or die ("Can't execute $sql: " . mysql_error());[/code] To this: [code=php:0]$result = mysql_query($query) or die ("Can't execute $sql: " . mysql_error());[/code] Also, you've left all my column names in, you need to change those to your column names. Regards Huggie
  17. I've just realised something you posted before... [quote] I think it is something about this line of code: [code=php:0]<?php virtual('/nimatest/Connections/nimatest.php'); ?>[/code] because i dont have a folder call Connentions and a pgae named nimatest.php, should i create it and what should i write inside of it? thank you very much! [/quote] Why's this line even in your code then?  I take it you didn't write this code?  If you didn't then you can't just randomly remove things.  It might be advisable to contact the person who wrote the code. Huggie
  18. In that case your sql statement is incorrect... Change this: [code=php:0]$result = mysql_query($sql);[/code] To this: [code=php:0]$result = mysql_query($sql) or die ("Can't execute $sql: " . mysql_error());[/code] And then run it again. Regards Huggie
  19. OK, in that case, it should be as simple as this: [code]<?php // connect to db include('connect.php'); // query for the record $sql = "SELECT col1, col2, col3 FROM table WHERE condition = 'value'"; $result = mysql_query($sql); // get the details into a single row $row = mysql_fetch_array($result, MYSQL_ASSOC); // echo the form echo '<input type="text" name="column1" value="'. $row['col1'] .'"><br>\n'; echo '<input type="text" name="column2" value="'. $row['col2'] .'"><br>\n'; echo '<input type="text" name="column3" value="'. $row['col3'] .'"><br>\n'; ?>[/code] Regards Huggie
  20. The line you've included at the top of the page is a request to apache and is probably generating some content headers of some kind which is why you're getting the error. You could changing this: [code]<?php virtual('/nimatest/Connections/nimatest.php'); ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) {   session_start(); } [/code] To this: [code]<?php ob_start(); virtual('/nimatest/Connections/nimatest.php'); // *** Validate request to login to this site. if (!isset($_SESSION)) {   session_start();   ob_end_flush(); } [/code] ...But I'm not sure that will work. Regards Huggie
  21. OK, a few simple questions first. [list] [*]Do you know how to create HTML forms with default values? [*]Do you know how to retrieve an individual row from your database? [/list] Regards Huggie
  22. Here's an example of what I meant... You can save this as [b]crform.php[/b] and run it as a test if you like. [code]<?php // Required for the session data session_start(); // Is the form to actually be processed if (isset($_POST['Submit'])){   echo "This has been processed, possibly emailed to someone, or saved to a database...<br>\n";   echo $_POST['data']; } // Are we just previewing (in a new window) else if (isset($_POST['Preview'])){   echo "This has NOT yet been processed, All we've done is re-echo the form and open a new window...<br>\n";   $_SESSION['data'] = $_POST['data'];   // Here's where we open the new window   echo "<SCRIPT LANGUAGE=\"javascript\">\n<!--\nwindow.open('crform.php?action=preview')\n-->\n</SCRIPT>";   echo "<form method=\"post\">\n";   echo "<input type=\"text\" name=\"data\" value=\"".$_POST['data']."\">\n";   echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\">\n";   echo "<input type=\"submit\" name=\"Preview\" value=\"Preview\">\n";   echo "</form>\n"; } // This is used for the preview window else if ($_GET['action'] == "preview"){   echo "This is your preview...<br>\n";   echo $_SESSION['data']; } // Nothing's been done, just show the form else {   echo "<form method=\"post\">\n";   echo "<input type=\"text\" name=\"data\">\n";   echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\">\n";   echo "<input type=\"submit\" name=\"Preview\" value=\"Preview\">\n";   echo "</form>\n"; } ?>[/code] Regards Huggie
  23. I'm not sure how that differs from what I suggested! I'll try to come up with some sample code for you later. Huggie
  24. ok, I think I'll take a back seat on this one.  If I get a chance later on I'll post an example of what I mean, which will submit the form, open a new window with the preview in, and display the original form in the original window with the values still in as they were before you pressed the preview button. Regards Huggie
  25. OK, I think you've missed my point.  By clicking preview, it does technically submit the form, but it only does what's in that condition, so in essence, it's not actually been submitted.  Nothing's been done with the data. Regards Huggie
×
×
  • 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.