Jump to content

Tuk

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

About Tuk

  • Birthday 05/24/1987

Profile Information

  • Gender
    Female
  • Location
    Canada

Tuk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Alright, here's the basics of it... I thought about using implode() to only delete the ones the user selected, but I couldn't make it work properly so I went the long route. if (isset($_POST['submitprocesstrade'])){ $tradingfor = mysql_real_escape_string($_POST['retaindbid']); $getitem = @mysql_query("SELECT itemname, originaluses, itemtype FROM itemdb WHERE dbid = '$tradingfor'"); $itemtrade = @mysql_fetch_array($getitem); $failflag = 0; $query1 = ""; $query2 = ""; $query3 = ""; $query4 = ""; $query5 = ""; $query6 = ""; $query7 = ""; $query8 = ""; $query9 = ""; $query10 = ""; $query11 = ""; $query12 = ""; if (isset($_POST['commonyarn1']) && $_POST['commonyarn1'] > 0 && is_numeric($_POST['commonyarn1'])){ $commonany = mysql_real_escape_string($_POST['commonyarn1']); $query1 = "DELETE FROM yarns WHERE yarnid = '$commonany'"; }elseif (isset($_POST['commonyarn1']) && $_POST['commonyarn1'] == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['commonyarn2']) && $_POST['commonyarn2'] > 0 && is_numeric($_POST['commonyarn2'])){ $commonsock = mysql_real_escape_string($_POST['commonyarn2']); $query2 = "DELETE FROM yarns WHERE yarnid = '$commonsock'"; }elseif (isset($_POST['commonyarn2']) && $_POST['commonyarn2'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['commonyarn3']) && $_POST['commonyarn3'] > 0 && is_numeric($_POST['commonyarn3'])){ $commonsport = mysql_real_escape_string($_POST['commonyarn3']); $query3 = "DELETE FROM yarns WHERE yarnid = '$commonsport'"; }elseif (isset($_POST['commonyarn3']) && $_POST['commonyarn3'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['commonyarn4']) && $_POST['commonyarn4'] > 0 && is_numeric($_POST['commonyarn4'])){ $commonbulky = mysql_real_escape_string($_POST['commonyarn4']); $query4 = "DELETE FROM yarns WHERE yarnid = '$commonbulky'"; }elseif (isset($_POST['commonyarn4']) && $_POST['commonyarn4'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['uncommonyarn1']) && $_POST['uncommonyarn1'] > 0 && is_numeric($_POST['uncommonyarn1'])){ $uncommonany = mysql_real_escape_string($_POST['uncommonyarn1']); $query5 = "DELETE FROM yarns WHERE yarnid = '$uncommonany'"; }elseif (isset($_POST['uncommonyarn1']) && $_POST['uncommonyarn1'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['uncommonyarn2']) && $_POST['uncommonyarn2'] > 0 && is_numeric($_POST['uncommonyarn2'])){ $uncommonsock = mysql_real_escape_string($_POST['uncommonyarn2']); $query6 = "DELETE FROM yarns WHERE yarnid = '$uncommonsock'"; }elseif (isset($_POST['uncommonyarn2']) && $_POST['uncommonyarn2'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['uncommonyarn3']) && $_POST['uncommonyarn3'] > 0 && is_numeric($_POST['uncommonyarn3'])){ $uncommonsport = mysql_real_escape_string($_POST['uncommonyarn3']); $query7 = "DELETE FROM yarns WHERE yarnid = '$uncommonsport'"; }elseif (isset($_POST['uncommonyarn3']) && $_POST['uncommonyarn3'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['uncommonyarn4']) && $_POST['uncommonyarn4'] > 0 && is_numeric($_POST['uncommonyarn4'])){ $uncommonbulky = mysql_real_escape_string($_POST['uncommonyarn4']); $query8 = "DELETE FROM yarns WHERE yarnid = '$uncommonbulky'"; }elseif (isset($_POST['uncommonyarn4']) && $_POST['uncommonyarn4'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['rareyarn1']) && $_POST['rareyarn1'] > 0 && is_numeric($_POST['rareyarn1'])){ $rareany = mysql_real_escape_string($_POST['rareyarn1']); $query9 = "DELETE FROM yarns WHERE yarnid = '$rareany'"; }elseif (isset($_POST['rareyarn1']) && $_POST['rareyarn1'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['rareyarn2']) && $_POST['rareyarn2'] > 0 && is_numeric($_POST['rareyarn2'])){ $raresock = mysql_real_escape_string($_POST['rareyarn2']); $query10 = "DELETE FROM yarns WHERE yarnid = '$raresock'"; }elseif (isset($_POST['rareyarn2']) && $_POST['rareyarn2'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['rareyarn3']) && $_POST['rareyarn3'] > 0 && is_numeric($_POST['rareyarn3'])){ $raresport = mysql_real_escape_string($_POST['rareyarn3']); $query11 = "DELETE FROM yarns WHERE yarnid = '$raresport'"; }elseif (isset($_POST['rareyarn2']) && $_POST['rareyarn2'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if (isset($_POST['rareyarn4']) && $_POST['rareyarn4'] > 0 && is_numeric($_POST['rareyarn4'])){ $rarebulky = mysql_real_escape_string($_POST['rareyarn4']); $query12 = "DELETE FROM yarns WHERE yarnid = '$rarebulky'"; }elseif (isset($_POST['rareyarn4']) && $_POST['rareyarn4'] == 0 && $failflag == 0){ $failflag = 1; errorbox("You don't have all the yarn required to make this trade!"); } if ($failflag == 0){ //no fail if ($_POST['commonyarn1'] > 0){ @mysql_query($query1); } if ($_POST['commonyarn2'] > 0){ @mysql_query($query2); } if ($_POST['commonyarn3'] > 0){ @mysql_query($query3); } if ($_POST['commonyarn4'] > 0){ @mysql_query($query4); } if ($_POST['uncommonyarn1'] > 0){ @mysql_query($query5); } if ($_POST['uncommonyarn2'] > 0){ @mysql_query($query6); } if ($_POST['uncommonyarn3'] > 0){ @mysql_query($query7); } if ($_POST['uncommonyarn4'] > 0){ @mysql_query($query8); } if ($_POST['rareyarn1'] > 0){ @mysql_query($query9); } if ($_POST['rareyarn2'] > 0){ @mysql_query($query10); } if ($_POST['rareyarn3'] > 0){ @mysql_query($query11); } if ($_POST['rareyarn4'] > 0){ @mysql_query($query12); } successbox("You've traded in some yarn!"); } include("./footer.php"); die(); } So as you can see, all the queries are executed in the same manner, yet for some reason only the first option works. Thanks for looking over it. -Tuk
  2. To make a long story short, I have a series of forms, where certain options are visible depending on what the user selected on the previous form. The final form processing is where I'm having issues. I have the following for each option, to check if that option was selected (this is all somewhat pared down for clarity): if (isset($_POST['option1']) && $_POST['option1'] > 0){ $option1 = mysql_real_escape_string($_POST['option1']); $query1 = "DELETE FROM table WHERE itemid = '$option1'"; } I have that basic thing for each of the options, where it assigns a deletion query based on each individual option. Later in my code, I have the following, which again checks if each option was selected (it's restated because it's after several error checks) then is supposed to run the query that was assigned in the previous part: if ($_POST['option1'] > 0){ mysql_query($query1); } if ($_POST['option2'] > 0){ mysql_query($query2); } if ($_POST['option3'] > 0){ mysql_query($query3); } (etc, for all the options) My problem is that the queries are not executing and I can't see any reason why not. Query #1 is working... it executes the deletion query and all is well, but if I try to select any options other than #1, the query doesn't execute. I tried echoing the queries within the second if statements above (where it runs the queries) and it's echoing them fine (and they look normal), so I know it's able to run the queries, it just isn't... Am I blind? lol. I must be missing something obvious because this is driving me crazy. Thank you in advance. Please let me know if you need more info.
  3. Thanks Pikachu2000, t'was a typo after all -- I didn't even notice I'd put $POST.
  4. Any ideas at all? This is killing me, lol.
  5. $select = mysql_query("SELECT * FROM CUSTOMER WHERE CUST_NO=1"); $array = mysql_fetch_array($select); echo $array['CUST_NO']; This will display '1' in this case.
  6. I have a form where members on my site can update their display name among other things. However, my script is returning the error for if nothing was inputted in the display name input box (members must provide a display name, can't leave that box blank) even though my text input box definitely has a value. The section of my form with the input box: <tr> <td class='sidebardark' width=40%><b>Display Name</td> <td class='D' width=60%><input type=text name=newdisplayname class='inputtext' value="<? echo $currentname;?>"></td> </tr> And the section in my form-submitted script that has the error that's displaying: $newdisplay = strip_tags(mysql_real_escape_string($POST['newdisplayname'])); if ($newdisplay == "" || !isset($POST['newdisplayname'])){ errorbox("You must set a display name!"); } Normally I'd think it was a typo on my part but I honestly can't see anything wrong with it. The current display name is showing up just fine in the input box. I asked it to echo $newdisplay above the error box and it echoed nothing so I have to assume it's not passing the variable correctly for some reason. Edit: If it matters, I haven't had any issues with text input boxes on this particular site before. Only this specific one.
  7. I wasn't clear enough in my description of how it's working, I suppose, as some of what you said doesn't apply. I also changed the names of files, etc. However, as I was typing this reply, I had an epiphany, and it worked.
  8. Nothing happens when I remove them. I am almost positive the problem I described is why this isn't working. I don't think the quotes have anything to do with it.
  9. I'm having an issue with dynamic image creation. I know what my problem is so I'm just wondering if there's a way to make it work, or if I'm out of luck. Basically I have an image and I want to display a dynamic string on it. I've looked up tutorials, etc, and eventually I got it working, except the string isn't showing, and I think it's because it's a variable. I got it to work perfectly by putting a static word as the string ('hello'), but when I changed that to a variable, the main image shows up but with no text on it. I believe my problem is that the variable is obtained by using $_GET then a select query to get the information from the database for that particular user. I have the dynamic image set up in a separate file (file names have been changed, but I know those aren't the problem): <? $image = imagecreatefrompng("image url"); $textcolor = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); imagestring($image, 1, 10, 10, "$variable", $textcolor); header('Content-type: image/png'); imagepng($image); ?> I then call on the image with this, in the file I want the image to be displayed in...: <img src=imagefile.php> So basically, here's my problem... I need to use a select query to get the proper information for $variable, but since the dynamic image file needs to define itself as an image/png content-type, adding in any other script such as a query will cause the image to break... I can't include anything for the same reason... When I was looking up how to do a dynamic image in general, the only examples I found had static strings, but I kept reading that you could use a variable instead... but now I'm trying and it's not working. :/ As a note, I tried doing the select query in a separate file and including it, and the image broke again. Any thoughts? Thanks.
  10. Thank you! I'm now encountering separate problems but I believe I can solve it all from here. Thanks so much for the response.
  11. Hello. I ran into a hitch today and still haven't been able to find a way around it. I was hoping someone here would see a solution. This script is for a browser-based game that allows users to own animals and feed them, etc. This particular file is where the users assign a food to their animals. It is a form with a loop to display all the animals owned by the user, each with a checkbox that has the animal's id# from the database as the value. Here is the checkbox input within the loop: <input type=checkbox name="whichanimal[]" value=<? echo $animals['aid'];?> Once they've pressed Submit, this is the script that runs to assign the proper food type (variable obtained from the URL using $_GET): $update_ids = @implode(",",$_POST['whichanimal']); $query = @mysql_query("UPDATE animals SET assignedfood = '$foodid' WHERE aid IN ($update_ids)"); All of this works perfectly fine. My issue is that I want users to be able to uncheck a checkbox and when they submit the form, it 'unassigns' the food (sets it to 0). My problem is that the checkbox is within a loop... My thought was that if there is an opposite command to IN (in the update query), I could use it to get all the animals the user owns who weren't checked and set their assignedfood to 0... Does such a command exist? Is there some other way I'm totally missing? Please let me know if you need anymore info, and thank you in advance for any insight. - Tuk
  12. Tuk

    Syntax Error?

    Thank you for the information, rajivgonsalves -- it worked. Wasn't aware of 'mod' being a function. Thanks! mikesta707 -- that is because I have an or die on the next line. Thanks anyway.
  13. I'm trying to execute an update script when someone presses a button... and it's telling me I have an error with my syntax. I don't see it, so maybe another pair of eyes will help. The update... if (isset($_POST['claimflag'])){ $flaggle = $_POST['retainclaimid']; $duuuude = $_SESSION[id]; $yoursnow = mysql_query("UPDATE flags SET mod = $duuuude WHERE flagid = $flaggle") or die("Error: ".mysql_error()); } And the error I'm getting...: "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 'mod = 1 WHERE flagid = 3' at line 1" 'claimflag' is the name of the submit button in the form. 'retainclaimid' is a hidden input value in the form, and is linked to the flagid, since the form is looped... 'flagid' is the primary index in the 'flags' table, and 'mod' is an integer in the flags table... Let me know if you need more info. This is driving me insane.
  14. Thanks for your reply, but I need it to be able to search specifically for what fields they enter. For example if they type something in the "userranch" field and also select something from the "userspec" dropdown menu, I need the results to be all cases in the database where both of those parameters exist within the same row.
  15. Hi all. This is driving me totally insane, especially since I can't find the answer anywhere online, though it seems like it should be so simple. Basically I have a form that will search the database, and it has a number of fields. I know how to display a queried field, but I want to make it so that if the user didn't fill in one or more fields in the form, the variables associated with those fields are omitted from the query, because as it is right now, when I hit the Search button, the results page comes up, but with no results listed, and no errors... so I'm assuming it's because it is looking in the database for blank spaces due to the fields not being filled in. I have tried pretty much everything I know how to do... I tried unsetting the variables if they are blank, but it had no effect at all. Here is the code for my search table... <table style="border: 1px solid #a8c562;" width=100%> <tr> <form action=/searchresults.php method=post> <td style="border: 1px solid #a8c562;" width=30% bgcolor=#cadd99 align=right>Name :</td> <td style="border: 1px solid #a8c562;" width=70%><input type=text name=susername size=30></td> </tr><tr> <td style="border: 1px solid #a8c562;" width=30% bgcolor=#cadd99 align=right>ID # :</td> <td style="border: 1px solid #a8c562;" width=70%><input type=text name=suserid size=30></td> </tr><tr> <td style="border: 1px solid #a8c562;" width=30% bgcolor=#cadd99 align=right>Ranch :</td> <td style="border: 1px solid #a8c562;" width=70%><input type=text name=suserranch size=30></td> </tr><tr> <td style="border: 1px solid #a8c562;" width=30% bgcolor=#cadd99 align=right>Tag :</td> <td style="border: 1px solid #a8c562;" width=70%><input type=text name=susertag size=30></td> </tr><tr> <td style="border: 1px solid #a8c562;" width=30% bgcolor=#cadd99 align=right>Specialty :</td> <td style="border: 1px solid #a8c562;" width=70% align=center> <select name=suserspec> <option value=""></option> '; include("/var/www/speciesdropdown.php"); echo' </td> </tr><tr> <td style="border: 1px solid #a8c562;" colspan=2 align=center><input type=submit name=submitusersearch value="Search!"></td> </tr></form> </table> And on the searchresults.php page, this is the section that is visible if the "submitusersearch" button is pressed... if(isset($_POST['submitusersearch'])){ echo' <table width=100% style="border: 1px solid #a8c562;" cellpadding=3><tr> <td bgcolor=#cadd99 align=center style="border: 1px solid #a8c562;">User</td> <td bgcolor=#cadd99 align=center style="border: 1px solid #a8c562;">ID#</td> <td bgcolor=#cadd99 align=center style="border: 1px solid #a8c562;">Ranch</td> <td bgcolor=#cadd99 align=center style="border: 1px solid #a8c562;">Specialties</td></tr> '; $usearchname = $_POST['susername']; $usearchid = $_POST[suserid]; $usearchranch = $_POST['suserranch']; $usearchtag = $_POST['susertag']; $usearchspec = $_POST['suserspec']; $userarray = mysql_query("SELECT * FROM players WHERE displayname = '$usearchname' AND id = '$usearchid' AND ranchname = '$usearchranch' AND ranchtag = '$usearchtag' AND speciality1 = '$usearchspec' OR specialty2 = '$usearchspec' OR speciality3 = '$usearchspec'"); while ($usrow = mysql_fetch_array($userarray)) { echo' <tr> <td style="border: 1px solid #a8c562;" align=center>'.$usrow['displayname'].'</td> <td style="border: 1px solid #a8c562;" width=10% align=center>'.$usrow['id'].'</td> <td style="border: 1px solid #a8c562;" align=center>'.$usrow['ranchname'].'</td> <td style="border: 1px solid #a8c562;" align=center>'.$usrow['speciality1'].'<br>'.$usrow['specialty2'].'<br>'.$usrow['speciality3'].'</td> </tr> '; } echo'</table>'; } Thank you for taking a look...
×
×
  • 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.