Jump to content

samus

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

About samus

  • Birthday 04/17/1987

Profile Information

  • Gender
    Female
  • Location
    Scotland

samus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yeah, I already made the function do exactely what your first two points were, and I was considering to that last point since, I have no clue as to why a ghost row is being made. I was wondering if the error (i.e. that ghost row) is because I haven't updated the table right, but it seems correct if it IS updating, BUT it is ALSO insert a new row but with out any values (as I said) except username and quantity = 0 *confused big time*
  2. Unless they have Web Server on a stick. I have that and all I need to do is type in localhost/ whatever.. Unfortuantely I don't know what is wrong, but from my eperience, web servers on sticks (although you may not have it) are abit tempermental.
  3. Hey there again, I am trying to make a shopping cart from scratch (college assessment) however I am having a problem with updating the quantity of an existing item on the customers cart. Any help would be great. On the home page, each item (from the database) has an "ADD ITEM" button in which it shall direct the user to the "cart" page, along with hidden values of quantity = '1' and the item's unique item number. On the cart page I have successfully created a function that shall first search through the cart table (which contains, unique id (auto_increment), username, item, name, cost, description, image, imagelarge, quantity) for the row which contains the "username" AND "item" previously POSTED from the home page. With the results I define the function to only UPDATE the row when the row number is more than 0 (since then I would have to INSERT the order if there wasn't any rows already in the table). Here is the following code. <?php //call to database connection file include ("connect_inc.php"); // getting the unique username from cookie $username=$_COOKIE['username']; // getting posted data from previous page to know what exactely to order $quantity = $_POST['quantity']; $item = $_POST['item']; // testing echo "$item"; ?> Table contents.... <?php //query the data in the cart table to later manipulate $query3="SELECT * FROM cart WHERE username = '$username' AND item = '$item'"; $resultagain=mysql_query($query3) OR DIE("Your SQL: " . $query3 . "<br/> Produced this Error: " . mysql_error()); $nums=mysql_num_rows($resultagain); if ($nums > 0){ $i=0; //set the results into variables $id =mysql_result ($resultagain, $i, "id"); $username = mysql_result ($resultagain, $i, "username"); $item = mysql_result ($resultagain, $i, "item"); $oldquantity=mysql_result ($resultagain, $i, "quantity"); $newquantity= $quantity + $oldquantity; echo "$id"; //Update data in Cart $query4 ="UPDATE cart SET quantity = '$newquantity' WHERE id = '$id'"; $result4=mysql_query($query4) OR DIE("Your SQL: " . $query4 . "<br/> Produced this Error: " . mysql_error()); if (mysql_affected_rows() == 1){ echo "<font='black'>This item has been added to your cart again!</font>"; echo "<table width='400px' border='0' cellspacing='1' cellpadding='0'>"; echo "<tr>"; echo "<td rowspan='4'><img src='$image' height='100px' width='100px' title='click image for larger picture' onclick=\"javascript: openwindow(\"$largerimage\" \"height=500px, width=500px\")\" ></td>"; echo "<td><b>$name</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td>£ $cost</td>"; echo "</tr>"; echo "<td>$description</td>"; echo "</tr>"; echo "</tr>"; echo "</table>"; } else { echo "echo?";} } else { //query to the cd table, to gain the item variables $query="SELECT * FROM cds WHERE item = '$item' "; $result=mysql_query($query) OR DIE("Your SQL: " . $query . "<br/> Produced this Error: " . mysql_error()); $i=0; //set the results into variables $item=mysql_result ($result, $i, "item"); $name=mysql_result ($result, $i, "name"); $cost=mysql_result ($result, $i, "cost"); $description=mysql_result ($result, $i, "description"); $image=mysql_result ($result, $i, "image"); $largerimage=mysql_result ($result, $i, "largerimage"); //insert the data in the cart table to later manipulate $query2="INSERT INTO cart (username, item, name, cost, description, quantity) VALUES ('$username', '$item', '$name', '$cost', '$description', '$quantity')"; $results=mysql_query($query2) OR DIE("Your SQL: " . $query2 . "<br/> Produced this Error: " . mysql_error()); //Just to confirm the data has been inserted into the table if (mysql_affected_rows() == 1) { echo "<font='black'>This item has been added to your cart!</font>"; echo "<table width='400px' border='0' cellspacing='1' cellpadding='0'>"; echo "<tr>"; echo "<td rowspan='4'><img src='$image' height='100px' width='100px' title='click image for larger picture' onclick=\"javascript: openwindow(\"$largerimage\" \"height=500px, width=500px\")\" ></td>"; echo "<td><b>$name</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td>£ $cost</td>"; echo "</tr>"; echo "<td>$description</td>"; echo "</tr>"; echo "<tr>"; echo "<td>$quantity</td>"; echo "</tr>"; echo "</table>"; } else {echo "goodbye";} } ?> Now what I am getting is that, I can successfully insert a new row with the right values. However, when the row is already there, it DOES UPDATE the quantity, but ALSO inserts a new row, with no values except the username and quantity = 0. How can I get rid of this... ghost row?
  4. Ok So I changed the names. However I still don't understand, btu I have a theory that it is mySQL matters, however, even if it is, does anyone else think how I could improve the actual PHP function? <?php //random number function generate_cust_ID() { srand ((double)microtime()*1000000); $number=rand(1,9999); return $number; } if (!isset($cust_ID)) { $cust_ID=generate_cust_ID($number); } echo "you are visitor number $cust_ID <br><br>"; require_once ('connect_inc.php'); $query = "SELECT di FROM random WHERE di = '$cust_ID'"; $result = mysql_query($query); $num = mysql_num_rows($result); if ($num> 0) { while ($num> 0) { mt_srand ((double)microtime() * 100000); $unique=mt_srand(1,9999); return $unique; $cust_ID=generateagain($unique); echo "hello"; $query = "SELECT di FROM random WHERE di = '$cust_ID'"; $result = mysql_query($query); $num = mysql_num_rows($result); } } else { $query2="INSERT INTO random ('di') VALUES ('$cust_ID')"; $results=mysql_query($query2) OR DIE("Your SQL: " . $query2 . "<br/> Produced this Error: " . mysql_error()); if (mysql_affected_rows() == 1) { echo "<center><font='black'>you have a unique number!</font>"; } } ?> Here is the database. CREATE TABLE `random` ( `di` INT NOT NULL , PRIMARY KEY ( `di` ) ) TYPE = MYISAM ; And here now the error. you are visitor number 1474 13/6/2007 18 : 11 : 14 Your SQL: INSERT INTO random ('di') VALUES ('1474') Produced this Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''di') VALUES ('1474')' at line 1 DO'H I know what was wrong XD ('di') Should've been (di) SOLVED :B
  5. It has been asked of me to create a randomised unique number. I have generated the random number, however I want to make it unique by cross referrencing the database. IF the number has already been stored it shall REPEAT the function until the new random number is not in the database. When it is unique it shall then be stored in the database. <? //random number function generate_cust_ID() { srand ((double)microtime()*1000000); $number=rand(1,9999); return $number; } if (!isset($cust_ID)) { $cust_ID=generate_cust_ID($number); } echo "you are visitor number $cust_ID <br><br>"; require_once ('connect_inc.php'); $query = "SELECT unique FROM unique_random WHERE unique = '$cust_ID'"; $result = mysql_query($query); $num = mysql_num_rows($result); if ($num> 0) { while ($num> 0) { mt_srand ((double)microtime() * 100000); $unique=mt_srand(1,9999); return $unique; $cust_ID=generateagain($unique); echo "hello"; $query = "SELECT unique FROM unique_random WHERE unique = '$cust_ID'"; $result = mysql_query($query); $num = mysql_num_rows($result); } } else { $query2="INSERT INTO unique ('unique_random') VALUES ('$cust_ID')"; $results=mysql_query($query2) OR DIE("Your SQL: " . $query2 . "<br/> Produced this Error: " . mysql_error()); if (mysql_affected_rows() == 1) { echo "<center><font='black'>you have a unique number!</font>"; } } ?> This is MY interpretation of how it may of worked (obviously it didn't) and this is the result I get. you are visitor number 6370 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/asmith/public_html/website/datetime.php on line 38 Your SQL: INSERT INTO unique ('unique_random') VALUES ('6370') Produced this Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'unique ('unique_random') VALUES ('6370')' at line 1 I have doubled checked the database and all the names look to be correct. If you have ANY suggestions of any other ways I could have this. The end result is to have this unique random number set as a cookie. Any help will be brilliant.
  6. Wooo. Nice colour theme, nice and bright. I think the main thing that is bringing you down is the background :/ I find it abit, hard on the eyes, since you have a white "border" around your main content. Also, the background is a gradient, however the background you have used isn't big enough to suit all resolutions. I suggest to make that final "dark" blue an image (even have it a few pixels width and tall - depending on the tile range it has) and set it in to your body tag as the background image. Then place the gradient background over onto of it (if you haven't already done so), and then the content onto to of it.
  7. Everyone needs to start somewhere.  And here I am. My name is Ashley, a girl.  I am 20 years old and I live in Scotland.  Ever since my big brother (6 years older) had a Nintendo console I have loved games, till this very day and beyond.  I always got the hand me downs from my brother. And one of those hand me downs was a computer.  I hated it!  I totally loathed it.  Never could imagine that "it" could produce better games than a games console.  However my courosity took over and I found Neopets!  NEOPETS?! :P  It was my first taste of HTML.  I loved it.  However, I was never of a logic mind.  I'm an artist. [url=http://samus-aran.deviantart.com]Shameless plug, I know.[/url] So computers were just.. a "thing" at the side.  Art, and art college was my real goal. But still, watching my brother (the logic one) work the computer like a wizard I was always jealous.  I wanted to make something so amazing with the computer.. I just didn't know what. Through the academy (high school) years I continued to draw and paint and colour.  I constantly doubt my artistic abilities, and even dropped out of a Higher Art course for the fact I just didn't think I was [i]good enough[/i].  By that time I had taken a grip of the internet and a graphics tablet.  I wasn't a social girl either.  Just sat at home playing video games or on the internet *laughs* When I finially did another Higher Art course, my logic again failed me.  I am horrible at discribing what I have in my head onto paper to make it sound like a story at a passing grade.  Even though my teachers told me how good I was at art, I just barely passed because of my writing skills.  That was August 2005.  I was depressed at my skills and swore I would never draw again....  No chance I was going into Art College.  However my parents convinced me to try a portfolio preperation class in a college.  And there I noticed... Web Development.  O:  That old flame sparked inside me again!  I was determined to be a web designer.  Logic AND Art skills.  I wanted to be an all rounder of a high quality! Even though I didn't have the grades to get into the course (I needed any sort of computer skills at high school, which I didn't take) but I convinced them that with the years of watching my brother that THIS is what I wanted.  They accepted me. 2 years on, I'm top of my class and heading for a degree in Internet Technologies, and hopefully an honors, and after that?  Who knows?! I know I'm not an ace at logic, but I will learn, learn, and learn some more.  That is why I'm here!  ^_^ Sheesh, I didn't mean to write a novel. Anyway, I'm Ashley and I love Coca Cola.
  8. Thanks obsidian. I'll do that! (: And yes, I'm using fireworks, 448191, you can tell?! *laughs* I'm really sorry it seems as though I don't know exactly to optimize the best to my ability. I "did" to the point were I thought they were, but obviously they aren't ; Let me try it out myself, if I can't seem to figure it out I'll report back, asking - if your willing to help - provide me with instructions to optimize using fireworks. (: EDIT~ Well, well, well, I'm optimizing haha. I didn't know that just adjusting the percentage of the quality reduced the file size so much. Thanks for that 448191!
  9. Heh, yeah, I did the design from scratch. But I guess everyone got through to the end with knowing that. My bad Very girly. I know. But I am open minded, and I have considered all of your replies! Spelling: I suck I know, I shall from now on, use the spell checker on firefox, or use Word to check and then place it in my pages. :B Link Menu: That is a toughy isn't it? I really wanted to have the links to the left, and the staggered li tags were just to try something new. I did adjust to the older IE browsers which don't work with that to have a image to appear behind it. But I am stuck as in what I could do. But I'll think around it - maybe have clouds over it in the li CSS tags. Castle: That is there for a place my archive links and what not from the blog I will implement during the summer. Considering how low it is, I will rise it up and my idea was to have a gif animation of butterflies (yeah, very girlyish ) flapping about, and what not. So as of now, the castle stays there until I see it doesn't suit when the blog is up. Font: Hmmm, when I think of sans-serif I was see "cartoony" theme. I guess your thinking - "what the heck, you saying your layout ISN'T cartoony?!" heh. But I DO understand the whole, it's too fancy. Good point What's your demographic target group?: Friends and Family <3 Content Padding: Wouldn't that make the content seem too narrow? I was more worried about that, IF it does, I could adjust the bacground image itself to be wider. Hmm? That could work. (: Optimize the images: To be utterly honest, I'm sure I did. Maybe the background I didn't, but I DID have the "title" image as a PNG 32 because of the transparency, and gif - as you knows - kills it. (sorry to anyone if I didn't repond to all the points, but I have looked at everyone!) Thanks very much (: You have provided me with alot of things to go over and I'm very happy to see such a great respond. Provided me with alot of help! I'll update when I have too updated. (:
  10. Layout wise, its simple and well presented. i.e. everything is clearly placed. The main deal is the site needs NEEDS graphics. A banner, a logo, anything! Children will be bored when they look upon it ): I'm just throwing an idea here, is to ask children to make lots of pictures so you can create a combination for your website and make it more personal. I think that would look cute and bring that "togetherness" that an anti-bullying website needs! Oh, and your Title "Bully Help Canada" highlights when you roll over it, even though it isn't a hyperlink.
  11. Oh man, thanks very much guys! Thank you so much! - since this is solved do I edit the thread title myself? Or does one of the moderators do it? Again, thanks
  12. Haha. Told you I was a clutz. HOWEVER o: Did what you said (: Well, I hope this is what you said. <?php $search=addslashes($_REQUEST['search']); $query ="SELECT * FROM search WHERE item LIKE '%$search%' OR calories LIKE '%$search%' OR discription LIKE '%$search%'"; $result =mysql_query($query) OR DIE("Your SQL: " . $query . "<br/> Produced this Error: " . mysql_error()); $num =mysql_num_rows($result); if($num==0) { echo "<br><font color='white'>Sorry, could not find what you were looking for. Please try again.</font>"; } else { $i=0; while ($i<$num) { $item=mysql_result($result,$i,"item"); $calories=mysql_result($result,$i,"calories"); $discription=mysql_result($result,$i,"discription"); echo '$item'; echo '$calories'; echo '$discription'; $i++; } } ?> And I'm getting this.
  13. I did what you asked frost110 "Parse error: parse error in /home/asmith/public_html/search1.php on line 51" Is what I got. Line 51 is the original query itself. I then put this, since I didn't know if you meant that what you added was meant to go AFTER frost110 query, or just because you added it after he made a post. So I did it both ways (what a dofus I am). $search = addslashes($search); //Added after Frosts comment $query ="SELECT * FROM search WHERE item LIKE '%$search%' OR calories LIKE '%$search%' OR discription LIKE '%$search%'"; $result =mysql_query($query) OR DIE("Your SQL: " . $query . "<br/> Produced this Error: " . mysql_error()); $num =mysql_num_rows($result); Got this from above. Then I tried it this way due to the misunderstanding of the posts ^-^; <?php $search = $_REQUEST['search'] $query ="SELECT * FROM search WHERE item LIKE '%$search%' OR calories LIKE '%$search%' OR discription LIKE '%$search%'"; $result =mysql_query($query) OR DIE("Your SQL: " . $query . "<br/> Produced this Error: " . mysql_error()); $search = addslashes($search); //Added after Frosts comment $num =mysql_num_rows($result); if($num==0) { And I still get the same error from earlier, still aimed towards the $query. In the first set of code (on this post), I took out the $search =$_REQUEST['search'] by mistake, whoops. Put it back in, and I got this. <?php $search = $_REQUEST['search'] $search = addslashes($search); //Added after Frosts comment $query ="SELECT * FROM search WHERE item LIKE '%$search%' OR calories LIKE '%$search%' OR discription LIKE '%$search%'"; $result =mysql_query($query) OR DIE("Your SQL: " . $query . "<br/> Produced this Error: " . mysql_error()); $num =mysql_num_rows($result); if($num==0) { "Parse error: parse error in /home/asmith/public_html/search1.php on line 51" Which is now the; "$search = addslashes($search); //Added after Frosts comment" Now, I know you're probably thinking "what an idiot", I'm trying my best, I really am Just such a long day. ANYWAY, I believe I know why I got that last error, due to the $search can't be set twice? o_O Maybe? God I'm hopeless. Heh.
  14. AGAIN, wow, so many new topics in one day (two ) Let me introduce myself (ack, not needed but I would like to, please don't stop me) I am Ashley Smith, and I'm studing to be a web designer (vague I know). Well, we all have to start somewhere, right? I'm 20 years old and studing HND at the moment for Multimedia Web Development, and hopefully next year complete a degree in Internet Technologies. Now, this is my first layout for a web site I bought. I admit there is not much content (sorry), however I will increase this when my studies are not on the top of the top to do list (: http://www.miniridley.com/ Even, just your personal opinions on the layout. And I "know" some of you gentlemen will not like the "girly" approach Remember, it's a personal website and not a portfolio. Thanks again!
×
×
  • 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.