Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Everything posted by EchoFool

  1. Oh your preg_match is different to mine, is that because mine is wrong or theres more than one way to do the same thing?
  2. Hmm so i can't use is_int if 123 returns false then ... =/ id have to use my current preg_match ?
  3. is_int() checks if the data type is an integer. He is getting input from input from a user, so the data type will always be a string. Does that mean is_int() will return false as the input is a string and not a number?
  4. Thanks! Also i use a similiar thing to check a inputted number is not decimal and is integer is there a simpler function than: //integer input check function preg($Var){ If(!(preg_match('~^\d+$~', $Var))) { return(0); }Else{ return($Var); } }
  5. Hey, Does any one know the regex to only allow the string to be letters only with no spaces/numbers/special characters? Hope you can help as i use: function textonly($Text){ return(preg_match('!^[^a-zA-Z]+$!', $Text)); } $Name = SQLskip($_POST['name']); $Name = str_replace(' ','', $Name); $Name = strtolower($Name); If(textonly($Name) != 1){ //BAD }Else{ If(strlen($Name)>15 OR strlen($Name)<1){ //BAD }Else{ //GOOD } } Yet some how it doesn't work as some one just managed to enter a blank name or it was a name with lots of spacebar presses i couldn't tell ... hope you can help
  6. Sure heres an example: INPUT FORM: <? function SQLskip($Var){ $Var = mysql_real_escape_string(stripslashes($Var)); return($Var); } if(isset($_POST['submit'])){ $Message = SQLskip($_POST['letter']); // insert query here }Else{ ?> <form method="POST" action=""> <textarea name="letter" class="textarea"> </textarea> <br><br> <input type="submit" name="submit" class="button" value=""><br><br> <a href="mail.php">Cancel Message</a><br> </form> <?php } ?> OUTPUT: //select query $QueryName $row = mysql_fetch_assoc($QueryName); echo nl2br($row['Message']); Field in database message example has the structure: http://i43.tinypic.com/sp887n.png Actual outputs: http://i42.tinypic.com/2mfiuxw.png So the input is fine as the structure remains in the database - its the output that goes wrong.
  7. Well for example when you make a post here and press enter twice to make a gap line the gap line disappears so: Hello Hello Becomes: Hello Hello Which is annoying
  8. Hmm doesn't seem to be the case. Still looses its structure, my input function has: mysql_real_escape_string(stripslashes($Var)); Could that cause structure loss?
  9. Does it go on input and output or just output ?
  10. Hey When i input to my database a message from a form that was typed into a text area - say there was paragraphs and gaps etc.. when the message is outputted at a later date the structure is lost and it is just a big chunk of text - this is happening for my forum posts but have no idea how to maintain the input structure upon output. Is there a a function of some kind for this solution?
  11. I tried that whilst awaiting a reply and failed i then tried without the "" and also structued with brackets around the variables like return() but still same white screen issue with the error: PHP Parse error: syntax error, unexpected T_RETURN on line 19 On all methods i tried
  12. I tried that but i get white screen - do the variables have to be comma seperated or something currently i just did : $EndValue = eval($StartValue $Symbol $Value);
  13. Hey I have 3 variables that have the following info: $Value = 100; $Symbol = '+'; $StartValue = 10; Now i want to put them together to add them together so i did this: $EndValue = $StartValue $Symbol $Value; Which would show as 10 + 100; but that gives an error how do i join them to make it execute as a mathematical thing?
  14. Is there any premade functions that change input of an integer in to a string of values like: Years : Months : Weeks : Days : Hours : Minutes Say the input was 120 minutes.... then the output would come out as Hours 2 But then if you had 1440 minutes it'll return 1 Day Or will i have to make the function?
  15. I was given the query from a user on phpfreaks a while ago - so i assumed that was how they are typed ...
  16. I have a query which checks a timestamp to "NOW()" but it returns nothing.. i echo it and i get nothing , yet with error reporting on it doesn't give me undefined error :S This is what i got: LastAction - 0000-00-00 00:00:00 -Timestamp format SELECT *, TIMESTAMPDIFF(MINUTE,'NOW()','LastAction') AS MinutesAgo FROM ".tablename().".user_data WHERE UserID='$UserID' Then i echo it later on : $row = mysql_fetch_assoc($SELECT); Echo 'Minutes ago: '.$row['MinutesAgo'];Echo '<br>'; Echo 'Username: '.$row['Username']; Echo '<br>'; The return gives: Any idea why this is happening?
  17. Was aimed at andrewgauger - sorry I think he was correct about the variables being the problem. I am testing it out now to see if its working - it appears to be Thanks
  18. Did it still return one when u had 3 rows in your table like mine does ?
  19. Andy-H no that doesn't really do what im looking for.. @ F1Fan If you look at the above rows examples : Table Fields: Row 1: RecordID 1 IP 127.0.0.1 UserID 1 Row 2: RecordID 2 ID 127.0.0.1 UserID 2 There 2 match on IP and so should return 1 Because the where clause is checking if 2 users having a matching IPs at least once in the list of rows: WHERE t1.userID='$UserID1' AND t2.UserID='$UserID2'
  20. No, the IP field would hold for example 127.0.0.1 etc the entire IP Such as: Table Fields: Row 1: RecordID 1 IP 127.0.0.1 UserID 1 Row 2: RecordID 2 ID 127.0.0.1 UserID 2 Row 3: RecordID 3 ID 127.127.127.127 UserID 1
  21. For this example situation i simply i replaced IP's with basic integers as in table example. It is meant to inner join on IP field = IP field which would make two IP's match thus the two users have an ip similarity.
  22. Hey, I use this query to check if a user has a smiliar IP to another user... yet it doesn't work... me and my friends ip's have a match but the query returns 0 suggesting there was no IP match.... Can some one explain what i got wrong? SELECT t1.IP FROM iplogs t1 INNER JOIN iplogs t2 ON t1.IP = t2.IP WHERE t1.userID='$UserID1' AND t2.UserID='$UserID2' LIMIT 1 Table Example: RecordIDIPUserID 111 112
  23. Would this be correct? SELECT IP FROM iplogs t1 INNER JOIN iplogs t2 ON t1.IP = t2.IP WHERE t1.userID='$UserID1' AND t2.UserID='$UserID2' LIMIT 1
  24. They are confusing me as to which are aliases and which are fields in your example :S
  25. umm i dont understand the COUNT(*) c then the i1 and i2 ? What are they?
×
×
  • 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.