Jump to content

Lashiec

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Lashiec's Achievements

Member

Member (2/5)

0

Reputation

  1. I've got the lovely task to create a shopping cart for our company to sell (actually, they've managed to sell two of them without it even being created...) Anyways, I put a mock up together a few months ago and I'm really thinking that some of the structure I used for the data shouldn't be the way it is. The companies have large whole goods, and with all of these whole goods comes a bunch of different parts that make up this whole good. So if they pull up whole good A they will get a little picture of it along with a listing of every part in that whole good, as well as current inventory, price, etc. The way that I had set these up was to serialize an array in the database with the part numbers, suggested qty, and reference number. This would have to be stored in some sort of text/blog field so that it had enough room to store all of this information. Some of the whole goods have up to 50 parts in them. But, now I'm really thinking that I should be breaking all of these apart into different rows in the database and just link them back to that whole good part number. So... I use to have: [1] => [qty] 2 [ref] 4a [num] 3043520 [2] => [qty] 4 [ref] 4b [num] 54620 and so on serialized into one row in a database that would be tied into that whole good.This could get quite long with 50 parts in that whole good. Not to mention that I also have to have some sort of tracking back if for some reason a part number got deleted from the main inventory database to know that it would be in the above array, so once something was deleted it would unserialize the array, check for the part number, remove it and so on... So a lot of extra work when I'm feeling something like the below could work much better: id ref sug num 1 4a 2 43534636 2 4b 4 45435435 and so on. There will more than likely be more things that I'll have to add on here once I get going more into this project. There are a few other things that I serialized and stored (shopping cart, previous orders) in the database too that I'm thinking should be broken out into their own separate rows. Not to mention when I pull the above out I need to grab the list of part numbers and queue the main inventory list for the price, number in stock, and so on, so I can't really do much of a join function on that which could save some time and PHP processing. So, after rambling on, does anyone have any suggestions or comments on how I should go about doing this? Is serializing data something that shouldn't really be done in this case, or at all?
  2. I have a table, it has users in it, a column named admin and the value for each user is either Y or N. What I wanted to do was have one query that would take all the information I needed and put it into one array based on the users being admins (Y) and at the same time take all the other users (N) and put them in another array... Something like: (admin = Y) [.0] -> [.0] -> user 1 [1] -> user 2 [2] -> user 3 (admin = N) [1] -> [.0] -> user 4 [1] -> user 5 So that when I get the data back from the database I can loop through all the admins and put them in one list and then loop through all the non-admins and put them in a list. Currently I just do a query, order it by admin, then take the entire return and run it through a loop and checks if each user is an admin or not and puts them into appropriate arrays according to that. It's not a problem really, I only have a few users for each installation of this program, but I was wondering if there was a more advanced / better way of obtaining the same results straight from the database.
  3. http://www.w3schools.com/PHP/php_cookies.asp Pretty straight forward and simple. They act just like any other variable that you create, you just set a duration on how long the persons computer stores the cookie.
  4. That's what gets me. I can try to upload abc.jpg and have it fail, then 20 minutes later upload abc.jpg again and it'll go through, resize, and be just fine. It's a really hard thing to track, because it just seems to act as if the file isn't there. I check in firebug and look at the posted values and it shows that it uploaded an image and all too. I'll check into it a little more tomorrow, I do have some javascript form validation going on, but I don't think that I validate an image upload box, and even then, it shouldn't alter the file before it uploads.
  5. I'll give it a shot tomorrow when I'm at work. I'll try getting one of my programs to give me the error with file uploads (although the error is usually something like it can't find the image file to get the image size/width since it does that first). Then, I'll try running the same file through the example you posted and see if it works. And yeah, I've got quite a few classes going on in my program. The only one that gets hit when I upload an image is the image class that takes care of resizing (and adding padding/backgrounds, but I don't use that here). Otherwise, if it doesn't need to resize the image it actually just does move_uploaded_file($file, "upload/$loc/$section/$filename");, but I guess everytime I've gotten the error I've told it to resize.
  6. I've had a weird re-occuring problem with file uploads that I can't seem to track the problem. I have multiple sites, so different servers, and it seems that every now and then when I upload a file and try to resize it (imagecreatefromjpeg) that it can't seem to find the image stream? I'm not sure why this happens sometimes and most of the time the file works just fine. I also noticed that after this happens, if I attempt to move the file (on my HD) to a new folder or something (still on my HD) that Windows will come back with an error saying that the file is in use or can't be modified. It's not just one server or one computer that does this either, I have a client that uploads images and the site resizes them. Every now and then I get a call and they say it's not working... Well, I go in and it works for me and then it works for them again later, and nothing was ever changed. Some sample code, in this program I take the $_FILES['tmp_name'] and pass that into a function which (if it needs to resize) it'll then take that and put it into this image class that I built. Inside the class it goes something like: $this->stream = imagecreatefromjpeg($this->file); $this->image = imagecreatetruecolor($this->width, $this->height); imagecopyresized($this->image,$this->stream,0,0,$this->offset_x,$this->offset_y,$this->width,$this->height,$this->old_width,$this->old_height); imagejpeg($this->image,$filename,'75'); There's some more in the code, but that's really all that is being ran. The rest is behind if statements that never get executed based on the uploads I'm doing. Yeah, I'm not really sure what could be causing the problem. And the fact that it only occurs every now and then really gets me.
  7. I'm using the jQuery library and do a lot of $(..).load('...url/') calls for my program. But, it has a problem with caching pages. I have a page that is paginated, and I allow the person to change the number of items to show per page. Once they change it then it does the load() command and refreshes the page, but most of the time it just refreshes back to the cached version. My page is a PHP page, and the number of items per page is stored in a session variable, and that all gets updated before the load() call even triggers. This happens on a lot of pages too, is there anything I can do with jQuery or my PHP pages to prevent this from happening?
  8. I don't think I'm getting quite what you're saying... This gives me an error: UPDATE `database`.`name` SET `qty`=MIN(0, qty - 5) WHERE (`part_number`='158654')
  9. I've got a field (int) and I need to add/subtract numbers from it for a shopping cart quantity field. The thing is, I can update the column with add/subtracted values, but if the value is 4 and I subtract 5 from it, it rolls over to 16475715 (it's unsigned). Is there a way to produce an error so that if it goes below 0, or above the maximum number, it won't do the update and will send an error out? Or... Should I just read the value out (4), do my math with PHP ($val = $val - 5), and then check if $val is within a reasonable range (0 to 16475715). I guess this way $val would become -1 and then error out since it's below 0 and all... Any ideas?
  10. I've got this shopping cart to build for some site, and I was wondering what a good way to do what I need to do. It's for a large company, so it'll be hit a lot and when people add an item to their cart I need it to take away the qty of the item that the warehouse has. But, the question I had was if the shopping cart doesn't get canceled or submitted, how can I take that temporary storage and return the qty of items from the cart back into the database? Is there some sort of thing that can run when a session variable times out (give I put qty and item in the session, that way when it times out the cart is destroyed and the inventory is returned to the database)? Or is there some better way to go about this? The project is in the starting phase of planning, so I wanted to work some of these things out before I got to involved in it. Thanks!
  11. I'm building a site, and it's using a lot of AJAX calls to php scripts. To make things easier for me I made one php file and put all my ajax scripts in there. So, when I call that page I send a $_GET variable to it and then in the php file I have a switch to go to a certain section of code that I want it to. It works fine and everything, but I have a really weird problem. With a few blocks of code it'll give me weird errors, like certain variables aren't there (notices) and some of my mysql syntax is wrong (mysql_error) and so on, but the weird thing is that the script actually completed just fine and did what it was suppose to. This can cause some problems because I'm usually echoing some variable that the ajax call will pick back up and do something based on what variable was returned... Now for the odd thing, I had this block of code, pretty much adding stuff to a database and creating a new column in a database. At the end of the code I did an echo of a variable, and it wouldn't work because it was saying I had a mysql error... But, when I put the echo before any of the code it doesn't give me the mysql error anymore. It works for this certain block of code because the returned variable is never changed, but for some it has to be at the end. I also noticed if I echo'd out all of my mysql strings it wouldn't give me an error, and they all looked correct. I'm using a database class I build myself and it doesn't seem to give me any problems when I use it, and I don't think that it is the problem because it's been used in multiple places already. Here is the code... Not that it'll make much sense since it's mostly using my database class, and I don't really want to post it (it just builds a string that gets passed to the database). If anyone has any ideas what could be going on with this that'd be great... I see no errors in any of my code, and even if it does send an error it seems to work anyways! case 'addtosection': { //adds a new column to section, addtosection.php echo $_GET['section']; $db->select_table($db_sections); $db->doit(array('select' => 'sec_order', 'where' => array(array('AND', "section::$_GET[section]")), 'limit' => 1)); $row = $db->output(); $db_order = $db->doit(array('select' => array('max' => 'db_order'), 'where' => array(array('AND', "section::$_GET[section]"))), 'math'); if(isset($_POST['showing'])) $show = 'Y'; else $show = 'N'; $id = $db->doit(array('insert' => array('sec_order' => $row['sec_order'], 'db_order' => ($db_order['math']+1), 'label' => $_POST['label'], 'type' => $_POST['type'], 'section' => $_GET['section'], 'showing' => $show)), 'insert id'); $name = ($id['insert_id'].'_'.strtolower($_POST['name'])); $db->doit(array('update' => array('name' => $name), 'where' => array(array('AND', "id::$id[insert_id]")))); $db->select_table($db_prefix.$_GET['section']); $db->doit(array('add column' => array($name => convert_sql($_POST['type'])))); } break;
  12. Does anyone have any idea of what could be happening? It's hit or miss on this thing, and it's not telling me anything in any of the apache or php error logs. I had some people who couldn't download these files use our internal IP and it worked fine... Of course it downloaded at like 10 megs a second since it's on our own network.
  13. I've got a problem with a server. It's running Mac 10.5.3 server, has MAMP running on it, and also the Mac server admin apache stuff. It use to just have MAMP, but the company I work for wanted Final Cut Server installed and that decided to activate the macs version of apache, php, etc. which kind of started working over my MAMP server. I had to switch my MAMP server to a different port (8000) because the version of php with the mac doesn't have the gd library in it. I tried to install a newer version of PHP on the server, but when I change the apache config file to load the new php5 module the server doesn't start, and even if I disable php all together it doesn't start... All of the above isn't too serious, since we just use on web application that needs the MAMP server. But, another issue popped up recently where people try to download files (around 40 megs each) and it stops at 99%. The weirdest thing is that on my home computer (Firefox 3) it worked fine. At work on a laptop (IE7) it stops at 99%. Another computer (IE7) it stops at 99%. Two clients of ours are having the same problem, one uses a Mac and the other is unknown. My mac at work I was able to download the file, and other files... Sometimes working, sometimes stopping at 99%. I use to have the MAMP server on port 81, but switched to 8000 incase a firewall was blocking it or something, but that didn't help. Even if I use the mac web server (default port 80) it's hit or miss on the file downloads too. Both apache servers are pointing to the same htdocs folder, if that has anything to do with this... But, I was told that this problem started a few weeks ago, before we even had to put Final Cut Server on our Xserve. Prior to that, the website hosting these files has been working fine since about February. I'm not a huge apache or web server admin really, more of a PHP person and general computer knowledge. So, any help would be appreciated. Thanks!
  14. Fixed the IE problem... The links are in a <li> tag and I had to set li {display:inline} to get rid of the space below the images.
  15. Thanks for the reply... I opened it in Internet Explorer and I see all the spacing issues... But, now to figure out what part of the CSS is causing this. It's more than just the Design/Web thing, they all seem to have an extra 10 pixels underneath them. I do tend to stick with the web safe fonts, but I'll look into picking a more suitable font.
×
×
  • 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.