premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
if(isset($_POST['delete_btn'])) { $checked = array(); foreach($_POST['checkbox'] as $value) { $checked[] = intval($value); } $query1 = "DELETE FROM tickets WHERE t_id IN (" . implode(", ", $checked) . ")"; $query2 = "DELETE FROM problems WHERE t_id IN (" . implode(", ", $checked) . ")"; } Try that and see. Also check what type the t_id field is. If it is a double, it will expect a double not an INT. And should it be a double? If the t_id field is an INT field then the above should work by converting the value coming from the form into an integer.
-
[SOLVED] return row with multiple parameters satisfied
premiso replied to neogemima's topic in PHP Coding Help
<?php //begin recent news doc @ $db = mysqli_connect('xxxxxx', 'xxxxxxx', 'xxxxxxx', 'xxxxxxx'); if (mysqli_connect_errno($db)) { echo 'Error: Could not connect to database. Please try again later.'; } mysqli_select_db($db, 'xxxxxxxxx'); $result = mysqli_query($db, "SELECT id, title, price FROM Equipmentposting WHERE type = 'General Laboratory' ORDER BY id"); $num_rows = mysqli_num_rows($result); if ($num_rows > 0) { while ($rowresult = mysqli_fetch_array($queryresult, MYSQLI_ASSOC)) { $id = $rowresult['id']; echo '<a href="equiparticle.php?id='.$id.'">'.$rowresult['date'].' '.$rowresult['title'].' '.$rowresult['price'].'</a>'; echo "<br>"; } } ?> How you had your script setup made no sense at all. I modified it and see if that gets you the desired results. -
Also $_post should be $_POST as php is caSe SenSItIve to variable names and array indexes.
-
if(isset($_POST['delete_btn'])) { $checked = array(); foreach($_POST['checkbox'] as $value) { $checked[] = $value } $query1 = "DELETE FROM tickets WHERE t_id IN (" . implode(", ", $checked) . ")"; $query2 = "DELETE FROM problems WHERE t_id IN (" . implode(", ", $checked) . ")"; } That should delete all checked records with ease.
-
[SOLVED] When should I use striptags mysql escape and htmlentities?
premiso replied to pneudralics's topic in PHP Coding Help
Just having a knowledge of what the functions do. How you had it, first you were escaping, that is probably fine but might cause some fuss with htmlentities. So it is better to put that after the entities. You want to strip html tags, but you had that last. Wouldn't using htmlentities before strip_tags defeat the purpose of using strip_tags? As that converts anything that might be interpreted by HTML to readable format? So if you want to remove HTML tags you first, strip_tags. Then if you want to convert items to their html entity you would then use that. Finally if there is anything left that MySQL may fuss about you would escape the string. Just like basic math, order of operations. It is often wise to understand what a function does before you use it, so you avoid issues like the above. Whether it would have cause an issue, I am not sure. But it was more or less redundant as strip_tags would of had no effect if used after calling htmlentities. -
<?php $input = array("NeW 1yOrK NotValid", "NewW YoRK Te valid", "valid new yourk", "valid", "not$ valid", " DULUTH"); foreach ($input as $in) { preg_match('~(^[a-z ]*+)~is', $in, $matches); if (!empty($matches[1]) && $matches[1] == $in) { $in = ucwords(strtolower($in)); $in = trim($in); echo $in . " was valid.<br />"; }else { echo "Invalid Characters in {$in}.<br />"; } } ?> I know the regex can be done in a better manner, but my regex is block is on today. Hopefully nrg_alpha comes along and fixes that part Till then, the above should work. Output from the above: Invalid Characters in NeW 1yOrK NotValid. Neww York Te Valid was valid. Valid New Yourk was valid. Valid was valid. Invalid Characters in not$ valid. Duluth was valid.
-
[SOLVED] When should I use striptags mysql escape and htmlentities?
premiso replied to pneudralics's topic in PHP Coding Help
It all depends on the content. Some times you want the HTML to be displayed (A blog for instance or a forum that allows html). Some times you expect a number, if you do check that it is a number if not do not allow it. There is not a "catch" all for it as different items require different needs. But how you are using the functions is the wrong order either way: mysql_real_escape_string(htmlentities(strip_tags($imhackerfree))); Would be the way to do it. But think about the data you should get. If the field is to be strictly a name, then yes, the above is perfect. It is to be a post that you do not want any html in at all, then yes. If you want to allow html in that field, no, the above would not suffice. -
[SOLVED] Slow query? - not really but added to slow_query.log
premiso replied to danesc's topic in MySQL Help
My bet is the FORCE INDEX portion. I have never used it (or seen it used) but why not just have that field in the table structure be indexed instead of putting it in the query. ??? -
That is kind of the point of system. To run a 3rd party application not associated to PHP. It calls on the "system" it self to run that application and return the results. Much like a command prompt in Windows or Linux. You can run an application from Command Line and get return values from it. But you need that application installed to run it.
-
You are trying to run java on a system that does not have java. Simple as that, you need the application to run it, the PHP is fine as far as I can tell.
-
$headers = 'From: sungpeng <admin@sungpeng.com>' . "\r\n"; mail("$email", "Thank you for registration", "Dear $firstname $lastname, Thank you for registering. Below you will find your username and password that will let you log in and begin to enter rental listings. Username: $email Password: $randompass ", $headers, "-fadmin@sungpeng.com"); Give that a try. The 5th parameter takes the -f which sets the from at the command line level. A lot of hosts require this to be set to official change the "from" address. Granted it is still good to put it in the header as well.
-
Sorry for the move, just saw javascript code The login you are trying to login to with cURL, is it your own page? If so, try the fix ignace posted. If not, we would need a bit more information. Does this not work? How does it not work, no cookie being set? If this is your site are you wanting to allow people cURL access? If so, why not create a non-javascript login for that?
-
I did not read the original topic, but just improving mtoynbee's code a tad <?php echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; echo "Month: <select name=\"month\" id=\"month\">"; $topValue = isset($_POST['month'])?intval($_POST['month']):"Select"; echo "<option value=\"please pick\" >".$topValue."</option>"; for ($i=1; $i < 13; $i++) echo "<option value=\"{$i}\">{$i}</option>"; echo "</select>"; Why have all those echos when you can have it easily generated for you
-
[SOLVED] whats the best way to extract a string from a string?
premiso replied to ballhogjoni's topic in Regex Help
If you want it to be done in regex preg_match is the function to start with. If you want some help, provide an example sentence and the word you want extracted. The key is, what singles that word out. How can you match that word? Is there a certain characteristic that can be used to parse it? Moving to Regex forum for you. -
[SOLVED] how do I notify a script when I receive an email?
premiso replied to ballhogjoni's topic in PHP Coding Help
It depends on your server. But if you have a Mail server you should have email accounts. With EMail accounts you should be able to have IMAP or POP access to them. You just need the address/username/password and you should be able to receive mail. That is how Outlook, The Bat, and Thunderbird, plus many other email clients tend to work. GMail allow for POP/IMAP access I know. -
I think you want to look in extending the class. See that page for an example.
-
[SOLVED] how do I notify a script when I receive an email?
premiso replied to ballhogjoni's topic in PHP Coding Help
You can use the IMAP functions to check for a new email. -
LMAO. It is basic math operations dude. I take it if you are taking a PHP class, you can at least do "some" PHP. But obviously you cannot read the text and have to probe for answers on forums and have people do the work for you instead of attempting to learn how to do basic PHP with BASIC math. Lazy people like you disgust me. EDIT: And even if you are not in a PHP class, you still cannot take the time to go on google and learn BASIC PHP and form handling on your own and how to implement the basic math operations instead of expecting someone to hand it to you on a silver platter.
-
Not to mention the above takes basic 5th grade math to accomplish.
-
Try it out and see. You can use var_dump on the value you are assigning the return set to to see what it is that was returned.
-
Will not work. Output has been sent to the browser Alternatively he could use a META tag instead of Javascript, but yea.
-
$sql = "some code"; if(mysql_query($sql)) { echo "Successful<br/>"; $page = "pagea.html"; } else { echo "Unsuccessful"; $page = "pageb.html"; } ?> <script type="text/javascript"> function timedMsg() { var t = setTimeout("location.href='<?php echo $page; ?>'",6000); } </script>
-
Nope. The only way would be to use IMAP with a cron job to check every x minute(s) to see if a bounce "Mail Delivery Failed" was received and parse that message for their email address. But that in its self can be un-reliable. As it can take longer than a few minutes to receive that notification depending on the mail server(s).
-
Now I wonder if I can add Ubuntu to this jumpdrive and if that will work under WinPE...time to do some more testing
-
[SOLVED] Insert Link into PHP mail() function?
premiso replied to dlebowski's topic in PHP Coding Help
Mail Manual Send it as an HTML email. Example #4 at the above link.