Jump to content

Sabmin

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by Sabmin

  1. This is really blowing my mind... the code is as follows the table, the column names everything is right and contains information but the variables aren't being filled... I don't get it... Anyone have any ideas or options I might not have thought of for debugging? $item_name = ("SELECT * FROM items WHERE id = '$grab_item'"); $que_items = mysql_query($item_name); while ($item_todel = mysql_fetch_array($que_items, MYSQL_BOTH)) { $name = $item_todel['name']; $desc = $item_todel['desc']; } echo ($name . "<br>" . $desc . "<br>" . $grab_item); the only variable thats set is grab_item, fetch_array throws no errors, if I plug in the query straight to the sql I get all the proper information... It's just not filling the two variables....
  2. alright so I got rid of the warning and later fatal error with the imagecreatefromjpeg and imagejpeg functions but now instead of a picture I get a whole lot of �����JFIF���������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ���C�
  3. so I have an array with a bunch of photos, and I'm trying to create a thumbnail of each to display on a page with a link to the full sized image but I'm getting the error in the subject title... if I just display the images in the array without trying to resize them it works fine... can anyone clue me into why this isn't working please. echo ("<a href='" . $img['file'] . "'>"); $new_width = (floor($img['size'][0] * ".25")); $new_height = (floor($img['size'][1] * ".25")); $tmp_img = imagecreatetruecolor($new_width, $new_height); imagecopyresized($tmp_img, $img['file'], 0, 0, 0, 0, $new_width, $new_height, $img['size'][0], $img['size'][1]); echo ("<img src='" . $tmp_img . " . $img['size'][3] , "' alt=''><br>\n"); echo basename($img['file']); echo "</a><br>\n";
  4. Trying to a. check if dir exists if not create it, and b. save an uploaded file to that directory. Nothing however is working but I'm pulling no errors, heres the code: $test_pic = $_POST['test_pic']; // I've also tried $test_pic = $_FILES["test_pic"]; : with no success if (is_uploaded_file($test_pic)) { if (!file_exists("tests/uploads/" . $test_name . "/")) { $create_test_folder = (mkdir("tests/uploads/" . $test_name)); if (!$create_test_folder) { echo "cant create folder"; die; } } $target_path = ("tests/uploads/" . $test_name . "/" . $test_name . "_1"); if (($_FILES["test_pic"]["type"] == "image/gif") || ($_FILES["test_pic"]["type"] == "image/jpeg") || ($_FILES["test_pic"]["type"] == "image/jpg") || ($_FILES["test_pic"]["type"] == "image/png") && ($_FILES["test_pic"]["size"] < 50000)) { if (!copy($test_pic, $target_path)) { echo "cant copy picture"; die; } } else { echo "file type or size bad"; die; } } and I understand its not at all public-safe but I'm just wanting to get it to work before I throw in the security. Thanks for the help!
  5. The code.... very simple: $punc_body = explode(". ", $body); foreach ($punc_body as $k => $v) { $v = ucfirst($v); echo $v . "<br>"; // this is only here for testing purposes. } $body = implode(". ", $punc_body); Why doesn't this work? I threw in the echo $v in which it shows that it is doing everything properly, however when I implode the array everything that was capitalized is reverted back to lower-case. Can someone tell me whats wrong or what I'm missing here please.
  6. Pagination thats the word I needed! Thanks
  7. Neither actually, just a personal project as I'm trying to learn all I can of the language.... It never occured to me to use a multi-dimensional array here maybe because I had so much trouble with them when I learned how to use them. Sub-concious block? But you're saying I shouldn't even do that, instead use the loop to display the content as its pulled rather than store it?
  8. Wow thanks for fast responses! I'm trying to define $res_1_date through $loop_date... Or in the beginnings of the loop I'm defining $loop_date with another variable, and what I need to do is grab information from the DB and assign it to the variable inside $loop_date, rather than just assigning it to $loop_date as its currently doing. As far as what I'm trying to accomplish I guess the best way to explain it is similar to a forum where your generating x number of topics per page based on the page number selected... Does that make more sense?
  9. I'm trying to loop through a database and assign the results to a variable that is created with the loop with the variables name based on which instance is currently running in the loop. I'll go ahead and include the code I thought might work, but I obviously have no idea what I'm doing in this case $i = 0; while ($i < $num_results) { $ip = ($i++); $result = ("$res_" . "$ip"); $loop_date = ("$res_" . "$ip" . "_date"); $get_result = "SELECT * FROM table WHERE id = '$result'"; $que_result = mysql_query($get_display); while ($sub_res = mysql_fetch_array($que_result, MYSQL_BOTH)) { $loop_date = $sub_res['date']; } $i++; } echo $res_1_date; Can anyone please clue me in on how I can get this to work please. It works with $result but it isn't working with the last $res_1_date... As I'm writing this I see where the problem is but just not quite sure how to make it work...
  10. I have a text field in my database that I'm pulling the contents of and parsing into an array, at which point depending on the users action I'm either adding to the end or searching for a specific value and removing it. I'm then converting the array back to a string and placing it back into the text field in the database. Everything works fine except for either an empty array value or a new line forcing its way to the front. Causing, naturally an empty value loaded onto the page that displays this part of the db. While I know theres a couple things in there that aren't necessary I was just too lazy to take them out before posting after attempting to find a way around this problem. But here is the bulk of the code. I appreciate any help! $to_add = "SELECT * FROM teams WHERE name = '$teamname'"; $que_to_add = mysql_query($to_add); while ($fetch_members = mysql_fetch_array($que_to_add, MYSQL_BOTH)) { $members = explode("\n", $fetch_members['members']); $members = array_filter($members); foreach ($members as $key => $value) { $value = trim($value); $new_insert[] = $value; } } $new_insert = array_filter($new_insert); foreach ($new_insert as $key => $value) { if ($value != "") { $to_insert = ($to_insert . "\n" . $value); } } $to_insert = ($to_insert . "\n" . $for_insert); $insert_ready = "UPDATE teams SET members = '$to_insert' WHERE name = '$teamname'"; $insert = mysql_query($insert_ready);
  11. This has been bugging me for quite a while and I've tried so many different things and just run into all kinds of problems... What I'm doing or trying at least is pulling data from a table displaying it into a multiple select box allowing the user the oppertunity to remove one or more options. As the code stands now I'm getting no value at all in the post variable, by taking the [] brackets out of the inputs name i was able to get the first selected option but the php code was then unable to remove that value from the database. I hope I'm explaining this well enough but the code follows I'd really appreciate some help or direction on this one. The FORM <FORM action='' method='post'> <select size='8' multiple name='remove_player[]'> <?php foreach ($members as $key => $mem) { if ($mem != "") { $mem = str_replace("-", " ", $mem); $mem = ucwords($mem); echo ("<option value='" . $mem . "'>" . $mem . "</option>"); } } ?> </select> and then the handler code: $to_remove = $_POST['remove_player']; $as_team = str_replace(" ", "-", $teamname); $as_team = strtolower($as_team); $for_remove = "SELECT * FROM teams WHERE name = '$as_team'"; $for_query = (mysql_query($for_remove)); foreach ($to_remove as $y => $z) { $z = str_replace(" ", "-", $z); $z = strtolower($z); } while($arr_remove = mysql_fetch_array($for_query)) { foreach ($arr_remove as $a => $b) { foreach ($to_remove as $c => $d) { if ($b == $d) { unset($arr_remove[$a]); } } } foreach ($arr_remove as $e => $f) { $add_replace = (mysql_result($for_query, 0, 'members')); $replace = ($add_replace . "\r\n" . $f . "\r\n"); $replace_mem = "UPDATE teams SET members = '$replace'"; $replace_q = (mysql_query($replace_mem)); } } echo "Member List successfully updated.<br>"; foreach ($to_remove as $h => $g) { echo ($g . " removed from the team.<br>"); } Also any time i try to print any part of the array/s I get no values but the database is being updated with 2 line breaks and a "3" at the end of the table which has me a bit confused as well. Thanks!
  12. I knew it would be something simple that I just didn't think of. Thanks a lot!
  13. I have an array titled $uhits that looks like this: Array ( [0] => Array ( [user] => test [hits] => 20 ) [3] => Array ( [user] => test3 [hits] => 6 ) [4] => Array ( [user] => test4 [hits] => 6 ) [1] => Array ( [user] => test1 [hits] => 4 ) [2] => Array ( [user] => test2 [hits] => 4 ) ) I've searched and tried so many different functions and am losing my mind after trying for 3 hours to be able to search for a specific user's value and then display it and the hits value. How in the world can I achieve this?
  14. Works wonderfully! Thank you! Unfortunately I forgot about another field I need figured in... I can get what I need done with more lines but if possible to use a single query I'd prefer to; so is there a way to get the syntax right when doing something along the lines of: SELECT (option where x = y or option 2 where x = z), COUNT(id) AS c FROM table GROUP BY c ORDER BY c LIMIT 20 Thanks!
  15. Ill give it a try thanks! Is it safe to assume that handling that much data will be possible in a real time page load?
  16. hmm every time I used it even with the ' I would get an sql syntax error until I changed '$table' to '$tab' in which it worked fine. Sorry to get off topic but what is "contains" in the query? I've never used or seen it for that matter, are you trying to get something that is just similar to the input? if so try: $query="SELECT * FROM contacts WHERE '$tab' LIKE '%$trimmed%' order by id"; otherwise try: $query="SELECT * FROM contacts WHERE '$tab' = '$trimmed' order by id";
  17. I found you can't use "table" as any part of your variable if you plan to use it in your query, try changing it to $tab and see if it works
  18. I have a table in mysql in which a field is constantly being filled with one of a thousand options. I'm looking to find out how I can grab the 20 most recent rows for each unique option filling that field. My other question is how realistic is queing up this much data if the field options were to reach a number of say 50-100 thousand options that I'm pulling the most recent 20 rows for each in terms of time it'll take to retrieve all the data. Is the database going to be fast enough or should I not bother with this feature? As always thank you very much for any help!
  19. I'm having a weird issue in which i'm trying to pull rows from a table based on the contents of specific fields. My query strings are: $ms = ("SELECT * FROM games WHERE game = 'test' AND playername = '$test' OR opponentname = '$test' ORDER BY playdate DESC LIMIT 25") or die ('Error: '.mysql_error ()); Which works fine until later I try to use: $ms2 = ("SELECT * FROM games WHERE game = 'test2' AND playername = '$test' OR opponentname = '$test' ORDER BY playdate DESC LIMIT 25") or die ('Error: '.mysql_error ()); What is weird is on $ms2 I found if I change it to: $ms2 = ("SELECT * FROM games WHERE playername = '$test' OR opponentname = '$test' AND game = 'test2' ORDER BY playdate DESC LIMIT 25") or die ('Error: '.mysql_error ()); It works... on one page, on the rest neither line works it just pulls every row in the table that fit one of the two name fields. Has anyone experienced anything like this or know why or a fix for this? Thanks!
  20. maybe this is a stupid question but I don't get it... echo $user->user; works but why doesn't: Code: $username = $user->user; echo $username; or at least how can I send this variable through a url into an iframe? a simple $var = ("url.php?user=" . $user->user); just returns a empty string.
×
×
  • 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.