Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Everything posted by EchoFool

  1. Not sure if I am doing this correctly so before i write my entire script thought I'd have some professionals on this site take a look tell me if I am doing this correctly? I have tried to create an array in a form to process on the next page but am getting problems with it. I have two entires the user has to do which is "select the items" and set the "quantity" of those items.. So lets say: ItemID |Quantity 3 4 2 2 7 1 These are the items the user picked and the corresponding quantities. Now i have applied that to my form below: <?php $Array = 0; While($row = mysql_fetch_assoc($GetItems)){ $ItemID = $row['ItemID']; $Quantity = $row['Quantity']; $Get = mysql_query("SELECT Name,Type FROM item WHERE ItemID='$ItemID' AND Trade='1'") Or die(mysql_error()); $row = mysql_fetch_assoc($Get); $Name = $row['Name']; $Type = $row['Type']; $Array++; ?> <tr> <td width="200" align="center" class="blackBold"><?=$Name?></td> <td width="200" align="center" class="blackBold"><?=$Quantity?></td> <td width="200" align="center" class="blackBold"><input type="text" size="16" name="Quantity[<?=$Array?>]" value=""></td> <td width="200" align="center" class="blackBold"><input type="checkbox" name="Checkbox[<?=$Array?>]" value="<?=$ItemID?>"></td> </tr> <?php } ?> This part is fine but the below part is my process page which i need help with i get an undefined error... to do with $ItemID (you can tell im a noob with arrays). This is my process: <?php If(isset($_POST['Button1']) && isset($_POST['Checkbox']) && isset($_POST['Quantity'])){ for($Array = 0; $Array < count($ItemID); $Array++){ if($Quantity[$Array]){ echo $ItemID[$Array] . " - " . $Quantity[$Array]; }else{ echo "Please insert a quantity for item id " . $item[$a]; } } } ?> It's so confusing! Not sure if I am going in the right direction? Am i ?
  2. Mysql almost goes hand in hand with php like burger goes hand in hand with chips. So theres one language that you should learn if you are to learn php.
  3. I need help with a serial array feature. At the moment i have: $items=serialize($_POST['array']); //takes the data from a post operation... But i want to add a mysql_real_escape_string safety to it but how would it be written? do i have to put the serial in brackets after the mysql function ? $items=mysql_real_escape_string(serialize($_POST['array'])); < would that work ?
  4. If its not in the same folder as the script your running you have to add what folder its in. Say one file is in : main root - test .php (this file wants to file test3.php) main root - subfolder - test3.php (you put include("/subfolder/test3.php") ) But if you want to do the opposite so say test3 needs to find test you can do: include("../test.php"); As the .. will tell it to look in the main root folder. Of in your case its not include but "location"
  5. I have a form with checkbox adjacent to certain data as like a "select this item" and many can be selected. But how do i in the form process get all the selected checkbox... do i name them all the same but change the value? I got this: <input type="checkbox" name="Checkbox1" value="<?=$ItemID?>"> But say 6 items are selected how do i get all 6 Item ID's? If i do $ID = $_POST['Checkbox1'] Cant see how that will work. On the other hand if i put the item id in the "name" attribute.. how would i make a script to get all the posted check box... the list could be huge =/ I'm really lost here on how to do it.
  6. Oh i see you have to tell it where the link is. Ok thankyou! How do i topic solve?
  7. I have two tables which have simple terms this: Item ID | User ID | Quantity 1 1 200 And the other has: Item ID | TradeAllowed | 1 1 With a query like this: $GetItems = mysql_query("SELECT useritem.ItemID,useritem.Quantity FROM useritem,item WHERE useritem.UserID='{$_SESSION['Current_User']}' AND useritem.Quantity > 0 AND item.Trade='1'") Or die(mysql_error()); But for some reason say the user has the item. and the item does exist in both tables which it should. When i echo mysql_num_rows($GetItems); it echo's 3. No idea where it gets 3 from. If anything 2 would make sense but it should only load one. Why does it display 3?
  8. Where is the topic solved button gone?
  9. Argh thank you ! Had the <= the wrong way round!
  10. I have a syntax error but not sure how to correct it. The idea is to change all rows with an id equal to or "less than" the value but i get this: This is what i put: $Change = mysql_query("UPDATE messages SET Staff='0' WHERE Staff='{$_SESSION['Current_User']}' AND Sender='$ID' AND MessageID=<'{$row['MessageID']}'") Or die(mysql_error());
  11. can we see the rest of your code it will help find the problem?
  12. Can it do that with time based? Cos thought that could only do it via number formats?
  13. Need some help, I have a query which when the report takes place I need to UPDATE all rows that are "before" the time that the query is run.. $Date = date("Y-m-d H:i:s",time()); Thats my time format. The rows contain a field "ReportedOn" so when the report completes... all rows that were reportedon "before" the process will change to what ever i need it to change to. This will help my staff from accidently reporting the same thing twice. Its just the WHERE clause i cannot figure out what do put
  14. It kills sessions so that any sessions related to the user is removed the user has to log back into the site before viewing any pages related to registered users only.
  15. Dont even need 2 tables. If this isnt to do with forum polls this is how i do it for a global site vote one vote per user: Voted | UserID | As a table then just echo a poll like this where ever you want? Are you male or female? Male = Value 1 Female = Value 2 Voted | UserID | 1 23 2 12 1 5 2 100 And if they try to vote again just do a query to check if their UserID is found in the table if it is then you just say "you cannot vote twice." If its related to forum polls then you need to add a "threadID" to the table.
  16. How does it not run properly.. what does it do wrong.. does it if no error comes up on your screen it wont on ours.. but turn error reporting on just to check everything.
  17. I have a question about: $Date = date("Y-m-d H:i:s",time()); This is going by my PC clock on localhost.. but by default when on a server will it go by the clock on the server? And how do you make up your own site time so it doesn't follow a Time Zone ?
  18. I have a function which i use to maintain the layout of the text block but i get an which i do not know what i have to do to correct. I have two areas on the same page using the same bb code function only i renamed the second one to avoid clashes. This is what i got for my 2 functions: 1 <?php function bbcode_format($Notes){ $Notes = htmlentities($Notes); $simple_search = array( '/\[b\](.*?)\[\/b\]/is' ); $words = array('[b]','[/b]'); $code = array('<strong>','</strong>'); $Notes= str_replace($words, $code, $Notes); echo $Notes; } ?> 2 <?php function bbcode_format($Infomation){ $Infomation = htmlentities($Infomation); $simple_search = array( '/\[b\](.*?)\[\/b\]/is' ); $simple_replace = array( '<strong>$1</strong>' ); // Do simple BBCode's $Infomation = preg_replace ($simple_search, $simple_replace, $Infomation); echo $Infomation; } ?> My error is this: Fatal error: Cannot redeclare bbcode_format() (previously declared in C:\xampp\htdocs\pendingreports.php:122) in C:\xampp\htdocs\pendingreports.php on line 161 Relating to the second function..
  19. Kinda except i can't use headers. Because the script is surrounded by 2 css files: include css1.css //script include css2.css This is because my site's content is always in the center div so i put the left right header and footer in my includes. And so as you would expect when i use a header i get the output already started. It is a pain!
  20. I have a form with 2 options, one is update, and one is report. Now if the button to report is pressed the action of the form needs to go to report page. Where as if the update button is pressed the action should not header to a different page for it should just stay on the current page and "update" the information. How ever i do not know how this can be done. If I put an action in the form entities then it will always header away so i need it only go to the action when one of the buttons is pressed. One of the unfortionutly things is i cannot use 2 separate forms as i have just found out before they are post $_POST-ing the same text area. And if i put the text area in both forms it will display on the web page twice which is not good . The only idea i can think of but i do not know if it will work is something like this: |<form1 - headers to filereport.php> | |<form2 - stays on the same page but just "refreshes" to allow the script to update> | | <button2> | |</form2> | |<button1> | |</form1>
  21. I keep getting this error on my message table: SQL query: ALTER TABLE `messages` ADD `ReportedOn` TIMESTAMP NOT NULL AFTER `ReportedBy` MySQL said: Documentation #1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause This is stupid.. if we can only have one cos then I will have to make an entirely new table just because of one field. The table has: Message ID | Sent On | ReportedBy | But i need to add a field which is | ReportedOn | But i get that error... what is the reason for this?
  22. I have a select box in my form which is this: <select name="MailBan" size="1"> <option value=""></option> <option value="0">First Time spamming mail box!</option> <option value="5">Second Time spamming mail box!</option> <option value="15">Third Time spamming mail box!</option> <option value="30">Fourth Time spamming mail box!</option> <option value="31">Fifth Time or more spamming mail box!</option> The problem is my form is not getting the option value its always coming out blank... this happens on any of the options . The first option it is meant to be blank to avoid any one accidentally having the first option set and hitting submit. Then in my php i have: <?php $Value = mysql_real_escape_string($_POST['MailBan']); Echo $Value; If($Value == ''){ ?> <br><br> <p align=center> <span class="NegativeMoney">You must choose the players offence from the box!</span><br><br> <a href="<?=$_SESSION['url1']?>">Back</a> </p> <br><br><br><br> <?php } ?> All i get it this error which is in the above script.. any help is much appreciated.
  23. Would any one here know is localhost using apache allows music files from the htdocs to work with BGsound? I cannot get mine to work , so wondered if my localhost is not allowing it ?
  24. Are you sure? I heard that $_SERVER['PHP_SELF'] can be unreliable. Probably a good point. I don't keep many php files in my web root so don't usually need to worry. What is so un-reliable about that? I use PHP_SELF all the time. Or you could do: Include("include.php?38383"); Then in the include If isset($_GET['38383']){ do script }else{ die; }
×
×
  • 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.