Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
[SOLVED] Query is forgetting to do something
Jessica replied to legohead6's topic in PHP Coding Help
Well it's like order of operations. If you have 2+2*5 - what do you do? It helps to add clarification, as (2+2)*5 is different than 2+(2*5) right? You do this in conditional statements in php also, like if($x==5 || ($x==2 && $y==2)). -
Use a mailer program like ezmlm.
-
Why do you want to put echo in a variable? I think you mean you want to echo the variable. [code] $var = "<strong>".($row1["sellrenttext"]).", ".($row2["typeofobjecttext"]).", ".($row3["city"]).", ".($row4["countrytext"]).", ".($row5["price"], 0, ',', ' ')." ".($row6["currencycode"])."</strong><BR><BR>".($row7["objectdes"]); echo $var; [/code]
-
[SOLVED] sorting alphabeticly based on a certain row
Jessica replied to legohead6's topic in PHP Coding Help
Yep, it is :) Does it hurt to add it? I normally have sorting options so my ASC vs DSC is set in a variable, so I tend to add ASC anytime. If that causes a performance issue I'd take it out, but I think it's fine right? -
[SOLVED] Query is forgetting to do something
Jessica replied to legohead6's topic in PHP Coding Help
No problem. Whenever I have more than one clause like that, I add parenthesis just to help me keep track of what each part is. -
[SOLVED] sorting alphabeticly based on a certain row
Jessica replied to legohead6's topic in PHP Coding Help
You need an order clause - I just ran thorpe's example on a table to check, and it returned them in order of PK (I did SELECT username FROM users and they were in PK order.) Try SELECT rownames FROM tablename ORDER BY sortedrow ASC; -
[SOLVED] Query is forgetting to do something
Jessica replied to legohead6's topic in PHP Coding Help
Have you tried adding parenthesis so it looks like this [code]$counting = "SELECT COUNT(*) FROM listings WHERE (title LIKE '%$search%' OR description LIKE '%$search%') AND cat='$ncat' ORDER BY id ASC"; $showing = "SELECT * FROM listings WHERE (title LIKE '%$search%' OR description LIKE '%$search%') AND cat='$ncat' LIMIT $start, $display";[/code] It should be prioritized that way automatically, but just in case, try this. -
Good job :) Don't forget to hit the solved button ;)
-
Where are you printing the next and last variables via echo? Shouldn't it be after you set them, somewhere you need to print them to the screen? You set them and then check a link to back, but nothing else?
-
[SOLVED] Trying to exclude everything but letters, nums, but spaces...
Jessica replied to Jessica's topic in Regex Help
Thanks! I am not sure why I was escaping the . - this is the first regexp I have written and despite reading a ton of tutorials and a quick reference book, I still just can't get my mind around it. It works beautifully now, thanks a ton! -
I want to allow only letters, numbers, and the . and _ character - nothing else, no spaces, no $!, etc. This is what I have. [code]if(preg_match("/[^A-Za-z0-9_\.]+$/", $this->username)){ $msg = "Please use only letters, numbers, and the following characters: _ and ."; }else{ $msg = "Username OK!"; }[/code] It works great when a user enters !@#$% etc, but when a user enters spaces in between two words, IE: john doe, it says Username OK. If they enter a space and another unallowed character it gives the error, but not if it's just two words with space. What is wrong with my regexp?
-
Does anyone know what I need to do here?
-
That is what I am trying to do, but when I do the ajax call, the php file says the $_FILES[] is empty. I am using mootools, I posted on their forum but no response yet. How would you do it?
-
How are they doing it then?
-
If the user enters the string of where the file is on their computer: C:\Documents and Settings\user\My Documents\image.jpg How can I upload it to the server without using a form like I would normally? What I am trying to achieve is an ajax image upload form, like the one on TheDailyPlate.com (see: http://www.thedailyplate.com/food-nutrition/food/generic/mashed-potatoes click on Contribute a photo of this item! - Don't actually do it, but that is what I mean. It uploads the image without refreshing the page.) Thanks!
-
[quote author=fenway link=topic=103135.msg410746#msg410746 date=1154881440] Why does the actual data have escape characters in it? [/quote] And, I have no idea why it's overescaped, when I put it in the database I used "mysql_real_escape_string(strip_tags($_POST['item']));" to get the string and put it in. In that case, 'item' was The Pirate's Code. Now I've gone into the database and changed the entry to "The Pirate's Code" unescaped, and the query SELECT name, id FROM all_items WHERE name LIKE '%Pirate\\\'s%' Finds it. WTF is going on here? Something is wrong with my database settings.
-
The actual record in the database is The Pirate\'s Code, and that's what I need to find. :( Here's what happens. The user enters pirate's in a search form. Then: $item = mysql_real_escape_string(strip_tags($_POST['search'])); $shop_info = "SELECT name, id FROM all_items WHERE name LIKE '%$item%'"; At that point $shop_info = "SELECT name, id FROM all_items WHERE name LIKE '%Pirate\\\'s%'" Which if I understand the escaping, it should find pirate\'s. And, I have no idea why it's overescaped, when I put it in the database I used "mysql_real_escape_string(strip_tags($_POST['search']));" to get the string and put it in. ARGH
-
SELECT name, id FROM all_items WHERE name LIKE '%pirate\\\'s%' MySQL returned an empty result set (i.e. zero rows). (Query took 0.0030 sec) SELECT name, id FROM all_items WHERE name LIKE '%pirate\'s%' MySQL returned an empty result set (i.e. zero rows). (Query took 0.0030 sec) SELECT name, id FROM all_items WHERE name LIKE '%pirate%' The Pirate\'s Code 30 Famous Pirates 32 I need to be able to search for the entry "The Pirate\'s Code" using "pirate\'s" or "pirate\\\'s". Why do the first two not work?
-
I am performing this query: $update_item = "UPDATE stall_transactions SET cleared = 1 WHERE stall_id = $stall_id LIMIT 50"; I want it to update the 50 most recent by either sold (datetime) or transaction_id (primary key). How can I ensure it does the 50 most recent? Thanks! ps: the new forum design is awesome!
-
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4252 bytes) in /home/www/sites/lifefiles.com/admin/uploadphotos.php on line 41 [code]function resize_image($type, $file, $max_width, $max_height){ $full_url = $file; $imageinfo = getimagesize($file); $src_width = $imageinfo[0]; $src_height = $imageinfo[1]; if($src_width > $max_width){ $divide = $imageinfo[0] / $max_width; } if($src_height > $max_height){ $divide = $imageinfo[1] / $max_height; } $dest_width = $src_width / $divide; $dest_height = $src_height / $divide; if($type == 2){ $src_img = imagecreatefromjpeg($file); (<-- Line 41) }else{ $src_img = imagecreatefromgif($file); } $dst_img = imagecreatetruecolor($dest_width,$dest_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); if($type == 2){ imagejpeg($dst_img,$full_url); }else{ imagegif($dst_img,$full_url); } imagedestroy($src_img); } [/code] The file is a very large one, and I need to be able to do the resize. How do I make it use more memory?
-
array_search(): Wrong datatype for second argument?
Jessica replied to Jessica's topic in PHP Coding Help
[!--quoteo(post=380786:date=Jun 6 2006, 04:26 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ Jun 6 2006, 04:26 PM) [snapback]380786[/snapback][/div][div class=\'quotemain\'][!--quotec--] make sure the $cards is declared as an array somewhere in your script. I am not sure if you have it in the 'cards.php' file or not. But if you don't have it there, and it's not a global variable that is set as an array, you'll need to add $cards = array(); before you use it in the array_search() function [/quote] Yeah it is [code]$cards = array(); $cards[1] = '2H'; $cards[2] = '3H'; $cards[3] = '4H'; (snip)[/code] is cards.php. I had to put it in the file outside of the function and do global $cards; Thanks! -
array_search(): Wrong datatype for second argument?
Jessica replied to Jessica's topic in PHP Coding Help
[!--quoteo(post=380782:date=Jun 6 2006, 04:22 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 6 2006, 04:22 PM) [snapback]380782[/snapback][/div][div class=\'quotemain\'][!--quotec--] What is the $dealer variable? You define it here: $dealer = $bj_info['dealer']; but that doesn't really help. If it isn't a string that would explain the error. Also you don't seem to define $cards here so it may not be set and if it is it may not be an array. Again if $card isn't a string and $cards isn't an array that is the source of the problem. [a href=\"http://us2.php.net/array_search\" target=\"_blank\"]http://us2.php.net/array_search[/a] [/quote] Every time I post on this forum, I manage to debug it right away :) I solved the problem by including cards.php at the start of the game_functions file, rather than IN the function. dealer is a string like 'AH9S' (Ace hearts, 9 spades) which go into the array to print the right images later on. So $card is a string and $cards is an array in cards.php Thanks anyway :) *SOLVED* -
I have a function for part of my blackjack game I am writing. There is an array $cards[] in the file cards.php. Here is the part of the function that is causing trouble in game_functions.php [code]function bj_points($bj_info){ include_once('cards.php'); $points = array(); $dealer = $bj_info['dealer']; $userhand = $bj_info['userhand']; $dpoints = 0; $dpoints2 = 0; $ppoints = 0; $ppoints2 = 0; $temp = strlen($dealer); for($i=0; $i<=$temp; $i=$i+2){ $card = substr($dealer, 0, 2);; $dealer_hand[] = $card; $dealer = substr($dealer, 2, strlen($dealer)); $cardkey = array_search($card, $cards); //<-- line 413 if($values[$cardkey] == 1){ $dpoints += 1; $dpoints2 = $dpoints; $dpoints2 += 11; }else{ if($bj_info['stage'] < 3){ $dpoints = $values[$cardkey]; }else{ $dpoints += $values[$cardkey]; } } } }[/code] And this is the error I get [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: array_search(): Wrong datatype for second argument in (snip)html/games/game_functions.php on line 413[/quote] Help? I tried adding global $cards; to the function but it didn't help.
-
SOLVED thanks to Google Groups & comp.lang.javascript. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]1. For the gender select, you don't define a value. So, instead of referencing: document.signup.gender.options[...].value You should reference: document.signup.gender.options[...].text 2. @ line 219 of rendered code: <option select>male</option> This should be either: <option selected>male</option> Or (even better and complient with the specified doctype): <option selected="selected">male</option> 3. @ line 206 of rendered code: <img src="'.$url.'hat_'.$hat.'.gif" (unparsed PHP code) [/quote]
-
Page: [a href=\"http://www.doublooncove.com/signup.php\" target=\"_blank\"]Game Sign Up Form[/a] Problem: In Firefox, the changes work fine. In IE, the images just disappear, and there is a broken image. The images are THERE. Some are blank images (like placeholders, since the male character is shirtless, his shirt is blank). But they do exist. Here is a sample of the code, there are several of these functions but they're all the same just different parts. [code]function change_gender(){ if(!document.images){ return }else{ document.images.bodygender.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + ".gif" document.images.hairback.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/hair/" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "/hair_" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "_" + document.signup.hair_color.options[document.signup.hair_color.selectedIndex].value + "_back.gif" document.images.hairfront.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/hair/" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "/hair_" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "_" + document.signup.hair_color.options[document.signup.hair_color.selectedIndex].value + "_front.gif" *snip* } }[/code] [code] <td><b>Gender:</b></td> <td> <select size="1" name="gender" onChange="change_gender()"> <? if($info['gender'] == 'female'){ print '<option select>female</option>'; print '<option>male</option>'; }else{ print '<option select>male</option>'; print '<option>female</option>'; } ?> </select> </td>[/code] Any ideas?