HuggieBear
Members-
Posts
1,899 -
Joined
-
Last visited
Everything posted by HuggieBear
-
PHP If statement not working... Help needed!
HuggieBear replied to leetstar's topic in PHP Coding Help
OK, two pointers for you... 1. [code=php:0]if ($difference = 1){[/code] should actually be [code=php:0]if ($difference == 1){ // notice 2 equals signs[/code]. 2. Your forth condition [code=php:0]elseif ($difference > 1){[/code] is only ever going to be true when the difference is 10, as the other 3 conditions take care of everything else. e.g The loop exits when the condition is true, so lets see which values equate to true on which part of the loop... [code] Difference 1 if ($difference == 1) True on 1st condition 2 elseif ($difference < 10) True on 3rd condition 3 elseif ($difference < 10) True on 3rd condition 4 elseif ($difference < 10) True on 3rd condition 5 elseif ($difference < 10) True on 3rd condition 6 elseif ($difference < 10) True on 3rd condition 7 elseif ($difference < 10) True on 3rd condition 8 elseif ($difference < 10) True on 3rd condition 9 elseif ($difference < 10) True on 3rd condition 10 elseif ($difference > 1) True on 4th condition - The only one 11 elseif ($difference > 10) True on 2nd condition 12 elseif ($difference > 10) True on 2nd condition 13 elseif ($difference > 10) True on 2nd condition . elseif ($difference > 10) True on 2nd condition etc. etc. etc.[/code] Might want to rethink that loop structure slightly. Regards Huggie -
WANTED: PHP whiz who is willing to help me with an output issue
HuggieBear replied to fran_456777's topic in PHP Coding Help
OK, someone had to ask... Why don't you want the user to see the form when they visit the page, why make them scroll down to see it? Regards Huggie -
File uploading taking up large amounts of memory
HuggieBear replied to mschrank99's topic in PHP Coding Help
I think it is normal when uploading. I don't know why, and I had hoped somebody would explain to me when I posted the same question here two weeks ago, but no joy. Regards Huggie -
When you submit the form, it posts the variables to the page, so lets sat for instance I select 'Work Order' from the drop down list and have filled all but one field in on the rest of the form. The value 'Work Order' gets assigned to the $_POST predefined variable, but it gets assigned to the 'type' part of it, because that's what our select list is called. It's the same as typing this [code=php:0]$_POST['type'] = "Work Order";[/code] with me so far? Now, when the form doesn't validate (because I didn't fill out one of the fields) it tries to display the form again, but this time we know what the user selected, as they've seen the form once, they selected Work Order, because that's what's in our $_POST['type'] variable. So all that foreach loop is doing, is saying, go through every one of the values in the $dropdown array and if it matches what's in our $_POST['type'] variable, then mark it as selected. I hope this helps. Regards Huggie
-
Old thumbnails are lingering in my file system,
HuggieBear replied to alwaysinit's topic in PHP Coding Help
When I say define, I mean assign a value to it, something like this: [code=php:0]$_SESSION['thumb'] = "smallthumb.jpg"; [/code] Nowhere in your code do you assign anything to a session variable called 'thumb'. So by looking at the code, I assumed you'd just copied one block that deleted the photo and changed the values to try and delete the thumbnails. The theory is almost right, but the practice not quite, hence why I got you to change the name to [code=php:0]$_SESSION['photo'][/code] as I know it existed, and you were calling your thumbs by the same name. Regards Huggie -
ok, well I don't know then, are you using any dynamic column names, like this: [code=php:0]SELECT * FROM tablename WHERE $column = '$value' [/code] Regards Huggie
-
File uploading taking up large amounts of memory
HuggieBear replied to mschrank99's topic in PHP Coding Help
I don't know why, but I had the same problem, it's possibly a memory leak issue. Add the following to the top of your page: [code] <?php ini_set("memory_limit", "50M"); ini_set("max_execution_time", "120"); ?> [/code] Regards Huggie -
It's probably the same problem, try... [code=php:0]$grabposts = mysql_query("SELECT * FROM im WHERE toid = '{$mem['id']}' ORDER BY `time` DESC"); [/code] Here's a list of [url=http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html]reserved words in MySQL 4.1[/url] Regards Huggie
-
Yes, but the column in your database is called 'hotelType', not 'Hotel'. Look at what the error message is telling you, somewhere in you're query, you have a WHERE clause looking for a column called 'Hotel', but it doesn't exist. Check your WHERE clause columns. Regards Huggie
-
'from' is a [url=http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html]reserved word[/url] in MySQL. Use backticks in your column names. This should work: [code=php:0] $postinto = mysql_query("INSERT INTO im (`id`, `toid`, `message`, `from`, `time`) VALUES('$newid', '$toid', '$message', '{$mem['username']}', '$time')") or die ("Can't insert: " . mysql_error()); [/code] Regards Huggie
-
Old thumbnails are lingering in my file system,
HuggieBear replied to alwaysinit's topic in PHP Coding Help
I can't see where you've defined [code=php:0]$_SESSION['thumb'][/code]? My guess is that you've put the thumbs into a directory called thumbs, but given them the same name as the large image, in which case try this: [code]<?php if( $_SESSION['photo'] != "nopic.jpg" && $_SESSION['photo']!="") { unlink("shared_files/thumbs/".$_SESSION['photo']); ?>[/code] Regards Huggie -
ok, try this: [code=php:0] $postinto = mysql_query("INSERT INTO im (id, toid, message, from, time) VALUES('$newid', '$toid', '$message', '{$mem['username']}', '$time')") or die ("Can't insert: " . mysql_error()); [/code] Let me know what the error says. Regards Huggie
-
Try replacing just this bit of code: [code] <select name="type"> <option> Please Select Type of Request <option> - Maintenance <option> - Telecommunications <option> - Work Order <option> - Other </select> [/code] With this: [code] <select name="type"> <?php $dropdown = array("Please Select Type of Request", "Maintenance", "Telecommunications", "Work Order", "Other"); foreach ($dropdown as $option){ if ($option == $_POST['type']){ echo "<option value=\"$option\" selected=\"selected\"> - $option</option>\n"; } else { echo "<option value=\"$option\"> - $option</option>\n"; } } ?> </select> [/code] You should be able to just swap it straight out. Regards Huggie
-
ok, change it to... [code] foreach (range(1, $no_of_tapes) as $no){ echo "<select name=tape[]>"; echo "<option value=30>30 min</option>"; echo "<option value=60>60 min</option>"; echo "<option value=90>90 min</option>"; echo "</select>"; } [/code] Regards Huggie
-
Try this: [code=php:0] $postinto = mysql_query("INSERT INTO im (id, toid, message, from, time) VALUES('$newid', '$toid', '$message', '{$mem['username']}', '$time')"); [/code] Regards Huggie
-
OK, here's an idea on how to get data from the database for your order page... [code]<?php // start a session session_start(); // put the array of id's into a string for use in the sql query $sqlitems = implode(",", array_keys($_SESSION['items'])); // connect to the database include_once('connect.php'); // run the query to get the product name from the database $sql = "SELECT id, name, FROM products WHERE id IN ($sqlitems) ORDER BY id"; $result = mysql_query($sql) or die ("<b>Unable to run :</b> $sql<br>\n<br>\n<b>Because:</b> " . mysql_error()); // echo a row for each of our product lines while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo "<tr><td>{$row['name']}</td><td><input type=\"text\" name=\"{$row['id']}\" value=\"{$_SESSION['items'][$row['id']]}\"></td></tr>\n"; } ?>[/code] It should work with the previous two pages. Regards Huggie
-
Create a variable from an array, separated by commas
HuggieBear replied to HuggieBear's topic in PHP Coding Help
Perfect, I'm loving the logic in that. Regards Huggie -
That's saying that the column Hotel doesn't exist in your database. Regards Huggie
-
I have the following array: [code=php:0]$numbers = array(1, 2, 3, 4, 5); [/code] Now how do I get this into a variable that looks like this: [code=php:0]$number_variable = "1, 2, 3, 4, 5"; [/code] I realise this is the opposite of something like explode() but wondered the easiest way to get it from an array to a variable. Regards Huggie
-
OK, that's fair enough. Try this: [code]<?php mysql_select_db($database_conTotal, $conTotal); $query_rsHotels = "SELECT * FROM tabHotel WHERE hotelType = {$_GET['hotelType']}"; $rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error()); $row_rsHotels = mysql_fetch_assoc($rsHotels); $totalRows_rsHotels = mysql_num_rows($rsHotels); ?>[/code] Regards Huggie
-
I'm going to be honest here. I've helped a lot on one of the other posts with getting you up and running, but I can't help but feel the architecture of this site is all wrong. For a start, the fact that you have a URL value called 'id' and another called 'Id' is very bad. In this instance, what do 'Id' and 'id' represent, I obviously know what hotelType represents. Regards Huggie
-
ok, here you go, this is the code for page 1. If you look at the bottom of this page, there's an example of page one and page 2. [code] <?php // start a session session_start(); // clear the cart if the action is clear if ($_GET['action'] == "clear"){ unset($_SESSION['items']); } // if a link has been clicked if (isset($_GET['product'])){ if (!isset($_SESSION['items'][$_GET['product']])){ // if it the first time it's selected, quantity is 1 $_SESSION['items'][$_GET['product']] = 1; } else { // if it's been selected before, increase it by 1 $_SESSION['items'][$_GET['product']]++; } } ?> <a href="products.php?product=1">Product 1</a><br> <a href="products.php?product=2">Product 2</a><br> <a href="products.php?product=3">Product 3</a><br> <a href="products.php?product=4">Product 4</a><br> <a href="products.php?product=5">Product 5</a><br> <br> <a href="products.php?action=clear">Clear Cart</a> <br><br> <?php // This is just a var dump so you can see things incrementing echo "<pre>"; var_dump($_SESSION['items']); echo "</pre>"; ?> [/code] You can try page 1 [url=http://dizzie.co.uk/php/products.php]here...[/url] and page 2 [url=http://dizzie.co.uk/php/products2.php]here...[/url] Once you have all of these id's in an array, you can use that array to get the descriptions from the database for on the order form page. Regards Huggie
-
ok, my advice is an array of product id's as the key and quantities as the value. I'll knock up an example in the next hour. Regards Huggie
-
Can you help fix my thumbnailing, it's distorting
HuggieBear replied to alwaysinit's topic in PHP Coding Help
I'll post some code that I use, I specify a maximum width and a maximum height and it resizes accordingly. Would that help? Regards Huggie -
ok, what about quantity, will there be a separate quantity for each individual item, or will they only be allowed to order one of each item? Regards Huggie