ralph4100
Members-
Posts
18 -
Joined
-
Last visited
Never
Everything posted by ralph4100
-
Hello! I have to tables that are similar in important respects but different enough that I want them independent of each other ([b]flag_requests[/b] and [b]tour_requests[/b]). The tables [b]flag_notes[/b] and [b]tour_notes[/b] keep track of user submitted notes regarding the rows in [b]flag_requests[/b] and [b]tour_requests[/b], respectively. What I want is to select the rows in [b]flag_requests[/b] and [b]tour_requests[/b] that have zero rows in their respective [b]flag_notes[/b] and [b]tour_notes[/b] tables, and order the results by a column [b]added[/b] (datetime) which exists in both [b]flag_requests[/b] and [b]tour_requests[/b]. In other words, the unaddressed requests, as per their having no notes about them. My pathetic attempt: [code]SELECT * FROM flag_requests, tour_requests WHERE COUNT( SELECT * FROM flag_notes, tour_notes WHERE flag_notes_request_id=flag_requests.id OR tour_notes.request_id=tour_requests.id )=0 ORDER BY added[/code] the tables: [code]CREATE TABLE `flag_notes` ( `id` int(11) NOT NULL auto_increment, `office_id` int(11) default NULL, `user_id` int(11) default NULL, `party_id` int(11) default NULL, `request_id` int(11) default NULL, `added` datetime default NULL, `body` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; CREATE TABLE `flag_requests` ( `id` int(11) NOT NULL auto_increment, `office_id` int(11) default NULL, `party_id` int(11) default NULL, `date_to_be_flown` date default NULL, `date_needed_by` date default NULL, `flown_for` varchar(150) default NULL, `occassion` varchar(250) default NULL, `special_instructions` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; CREATE TABLE `tour_notes` ( `id` int(11) NOT NULL auto_increment, `office_id` int(11) default NULL, `user_id` int(11) default NULL, `party_id` int(11) default NULL, `request_id` int(11) default NULL, `added` datetime default NULL, `body` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=52 ; CREATE TABLE `tour_requests` ( `id` int(11) NOT NULL auto_increment, `party_id` int(11) NOT NULL, `type` int(11) default NULL, `confirmed` datetime default NULL, `cancelled` varchar(200) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;[/code]
-
sometimes programming makes you feel so dumb.
-
ok here's the code: [code]<?php function checkFor($n) { //let's see if this syntax works... //it's supposed to be true for any variation (regarding capitalization) //of the word 'reset' echo 'checking \''.$n.'\'...'; if(stristr('reset',$n)!==false) { echo 'true'; } else { echo 'false'; } echo '<p>'; } checkFor('reset'); checkFor('RESET'); checkFor('does not contain '); checkFor('does contain reset'); checkFor('rEsEt'); checkFor('ReSeT'); checkFor('reeeeset'); ?>[/code] and here's the output [code]checking 'reset'...true checking 'RESET'...true checking 'does not contain '...false checking 'does contain reset'...false checking 'rEsEt'...true checking 'ReSeT'...true checking 'reeeeset'...false[/code] stristr() should not return false for 'does contain reset' because 'reset' is in the string 'does contain reset'. get me? what's going on here? running php 5.2 btw...
-
usually the mod operator is best for this but your question is hard to understand. try to explain more fully what you are trying to do
-
Incrementing and decrementing URL variables
ralph4100 replied to mjurmann's topic in PHP Coding Help
try over two lines of code like this [code]<?php $plusone=$row_Recordset1['id']++; $minusone=$row_Recordset1['id']--; //then echo as needed //the problem I think is that when you can't do calculation while echoing [/code] -
Unwanted back slashes from form-to-email script....
ralph4100 replied to Skeleten Neteleks's topic in PHP Coding Help
in case anyone was wondering that code is from wordpress -
whew that was a tough problem
-
THANK UUUUUUUUU
-
oh my god i am so fucking dumb
-
btw the code above is generic
-
$i<=3 would mean 4 iterations if it begins with 0 lol I don't know about your list method why not just use mysql_fetch_array [code] <?php db_connect(); $q="SELECT * FROM table LIMIT 1"; $r=mysql_query($q); $counter=0; while($row=mysql_fetch_array($r)&& $counter<3) { echo $row['column1'].' tada! '.$row['column2']; $counter++; } ?>[/code]
-
htmlentities is SUPPOSED to do what u want but I am having problems with it see my topic hahaha
-
man that is a perplexing PHP problem
-
if u have a good head on your shoulders u can figure out the rest from this http://www.phpbuilder.com/columns/akent20000610.php3?page=6
-
you probably didn't close the <?php with a corresponding ?> so when it gets to html code it sees the < and has a syntax error
-
ok so anyway if u can read the functions above, makeUserInputSafe() runs $_REQUEST through a foreach, calling no_html() and quote_smart() for each memeber of the $_REQUEST array. should be simple no? except when I input <script> in the name field it doesn't get un-html-ed if u know what i mean... when i run a sample call of the function like echo htmlentities('<evil><script>'); that manages to do the trick why not now!!!!!!!!!?????????
-
looks like i'm having a bit of trouble with this site too!
-
Hello! I'm having a bit of trouble getting htmlentities to turn '<' and '>' etc. into their safe counterparts < and so forth. Anyway I've written a function to call before processing the forms on my page: [code] function makeUserInputSafe() { //fucking users... foreach($_REQUEST as $key=>$value) //ugh php5 would have let me pass the value as reference but noooooo... { echo '...making '.$key.'=>'.$value.' safe...'; //this was added for debugging purposes. $_REQUEST[$key]=no_html($_REQUEST[$key]); $_REQUEST[$key]=quote_smart($_REQUEST[$key]); echo 'safe. ( '.$key.'=>'.$value.' )'; } return true; } function no_html($value) { $value = htmlentities(trim($value)); return $value; } function quote_smart($value) { // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not a number or a numeric string if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } [/code]