Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. If you're doing anything with much depth/efficiency is important, the following article would be a good read: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
  2. The first parameter of the getimagesize should be a filename, not an image resource. Surely you know the size of an image if you've just created it?
  3. The do...while loop in the above code is an infinite loop - it will execute indefinitely, unless it is explicitly broken out of with a break statement. So yes, that loop will run until either of the two if statements evaluate to true. I've never done any java, but i would guess that the function searches some sort of list structure.
  4. Or, shock horror, you could use the string repeat function. Sometimes i wonder why google bother making a search engine.
  5. Err, no. You still haven't changed it. Try actually looking at what's been posted and what you're posting.
  6. No, it's not. The final closing brace of the script closes this if statement: if(isset($_POST['submit'])) { You basically need to restructure your code. You need to check to see if the username is in use after checking that the form has been submitted (the isset() if statement) and checking that the user provided a username and password. You should only insert if all those criteria are met (that is, the form has been submitted; it was submitted with a username and password provided; and the username doesn't exist.
  7. I'm not sure I follow your question. As you showed in your code, you can include another file's code with the include() function. Are you asking how to call a function within that included file? If so, you call a function in exactly the same way as you normally would. When you include a file, it is exactly as if the code in that included file was present in the file doing the including. I.e. The following combination of foo.php and bar.php is identical to foobar.php: foo.php: <?php include("bar.php"); bar(); ?> bar.php: <?php function bar(){ echo 'foobar'; } ?> foobar.php <php function bar(){ echo 'foobar'; } bar(); ?> If that wasn't what you were asking, then please rephrase your question.
  8. The opening brace of the else statement in this section of code: if(mysql_num_rows($check) == 1) { echo "Username Already In Use."; } else { Is not closed. Though this is the cause of the error, you appear to have further problems. You are checking to see if the username exists prior to checking whether or not the form was submitted and prior to defining $username. I think you may need to rethink your logic.
  9. To me, this whole thing we call life seems pretty pointless if you don't have kids. Not that i'd really be wanting kids right now. Not sure balancing university and children would work out so well.
  10. The mysql_query() function returns a resource - never a specific value from the database. Therefore, comparing $usage to it doesn't make sense - you need to retrieve the actual result from the resource (either with one of the mysql_fetch_xxx functions or mysql_result). Second, this line: $updateuser=mysql_query(UPDATE `radius`.`usergroup` SET `GroupName` = 'penalty' WHERE Username = '$user'); Executes the query. Therefore, it is executed regardless of the truth of the if statement. You could assign the query string to a a variable prior to your if statement and then execute it inside the if statement, or just do the whole thing inside the if statement.
  11. You should be using single quotes around your imploded list of IDs: $query_FLmembersGetRS = "SELECT username, photo, imgtype FROM members WHERE id IN ('" . implode(',',$FLabba) . "')";
  12. Where is this array of information coming from? Are you sure the unit used for size_download is bytes? Edit: That didn't make much sense - ignore.
  13. You're correct that the required syntax to access an element of an array is like this: $array['key']; //quote are unnecessary if the key is an integer: $array[1]; However, you may run into syntactical problems when you try to use this in a query. For example, if you try this: mysql_query("SELECT * FROM table WHERE somefield='$array['key']' "); You'll have an error in your query. Strings inside the query must be contained within quotes. In this case, we're using double quotes to demarcate then entire query, so we might use single quotes to delimit the string that somefield must be equal to. However, we're also using single quotes around our the key of our array. MySQL then gets confused. There's a variety of solutions to this (such as switching to doubles to contain the string somefield must be equal to and escaping them, or using concatenation) but, handily, PHP doesn't require single quotes around keys of arrays that are strings if that array is inside double quotes. Thus, this is valid: mysql_query("SELECT * FROM table WHERE somefield='$array[key]' "); Hope that clears up some of the problems with array syntax. By the looks of your code, i'm assuming it was very much pseudocode - you don't actually execute the query and the THEN token isn't used in PHP amongst other errors. If you need further help, you'll need to post some actual code. And finally - if you're faced with using a query inside a loop, it's quite possible a neater solution could be arrived at by using a join. Again though, we'd need more information about your database structure and what you're trying to achieve to help (and the post would be more appropriately placed in the MySQL board).
  14. You shouldn't be storing the actual image in your database - you should store the path to where it is on your server. You then echo out an image tag with the path, which can be done inside the loop just like the other data.
  15. Were you wanting something like this? <?php $sql = "SELECT fid,uid FROM friends_list WHERE (`uid` = '$FLgetUID' OR `fid`='$FLgetUID') AND status = '1'"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $array = array(); while($row = mysql_fetch_assoc($result)){ $array[] = $row['fid']; $array[] = $row['uid']; } echo '<pre>'.print_r($array,1).'</pre>'; ?> If not, you're going to need to explain your problem a bit more carefully. Oh, and there's no need to select the database before each query. Once is sufficient (unless it changes).
  16. You need to pass something to identify the particular image to a new page. If, as i would hope, you have a unique ID in your database table, then you might generate links like: http://www.yoursite.com/viewimage.php?pic_id=323; You would then do something like this in viewimage.php: <?php $pic_id = (int) $_GET['pic_id'];//int cast to prevent SQL injection $sql = "SELECT * FROM yourtable WHERE id=$pic_id"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $row = mysql_fetch_assoc($result); //print out information - a caption for example echo 'Caption: '.$row['caption']; ?>
  17. You'll need to use braces: $sent = mail($to, $subject, $message, $headers) ; if($sent){ ?> <html><body><table><tr><td>blah blah blah code code code</td></tr></table></body></html> <? }else{ print "We encountered an error sending your mail, please try sending an email to trent@studio9design.info or calling us at 715-688-9640"; } ?>
  18. If we're talking perceptions of the group of people by others, then certainly all but 3 is true. Isn't your some-what extensive list justification for not specifying what they might do it for?
  19. lol. I've just had visions of people wondering which state N/A is. It's not so much not applicable, just a different name. As waynewex said, our county can be considered an equivalent of a state as far as addresses go. Yup, postcode and house number is pretty much sufficient.
  20. Isn't that just a lot more effort? If you wrote your code so it was more self-documenting, you would need so many comments. Comments should be used to explain the program in general, large parts of it or any oddities in the code. As for any other reasons - not really. There's certainly no added security issues; all of the methods of input can be faked by the user, so it makes no difference. It's more to do with personal preference.
  21. Personally, i don't like using request as it's not immediately obvious where the data comes from and thus reduces read-ability and makes your code harder to understand.
  22. Why has PHP freaks suddenly become a perceived store of good ideas?
×
×
  • 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.