Jump to content

mhodge_txs

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by mhodge_txs

  1. @xxreenaxx1. You got two options. Either show me what you got now and I can help you go through the code to find out why its doing what you say it is, or create a new table called info in a test database importing the SQL I provided, and create a new index.php page with the php code I provided and then you can see whats happening.
  2. SQL CREATE TABLE IF NOT EXISTS `info` ( `Que_ID` int(11) NOT NULL AUTO_INCREMENT, `Que_Question` varchar(255) NOT NULL, `Que_Choice1` varchar(255) NOT NULL, `Que_Choice2` varchar(255) NOT NULL, `Que_Choice3` varchar(255) NOT NULL, `Que_Choice4` varchar(255) NOT NULL, PRIMARY KEY (`Que_ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `info` (`Que_ID`, `Que_Question`, `Que_Choice1`, `Que_Choice2`, `Que_Choice3`, `Que_Choice4`) VALUES (1, 'What Color is the sun', 'red', 'green', 'blue', 'white'), (2, 'Are IPhones cool', 'yes', 'no', 'maybe', 'who cares'); PHP <HTML> <BODY> <?php if($_POST){ echo "<pre>"; print_r($_POST); echo "</pre>"; }else{ $dbhost = 'localhost'; $dbuser = 'Your_Username_Here'; $dbpass = 'Your_Password_Here'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db('phpfreaks', $conn); $query = 'SELECT * FROM info'; $result = mysql_query($query); $counter = 1; ?> <form action="<? echo $PHP_SELF; ?>" method="POST"> <?php while( $info = mysql_fetch_assoc($result)) { echo "{$info['Que_ID']} <br />\n"; echo "<input type='hidden' name=\"Que_ID_{$info['Que_ID']}\" value=\"{$info['Que_ID']}\" /> "; echo "{$info['Que_Question']} <br />\n"; echo "<input type=\"checkbox\" name=\"Que_ID_{$info['Que_ID']}[]\" value=\"{$info['Que_Choice1']}\" /> "; echo "{$info['Que_Choice1']} <br />\n"; echo "<input type=\"checkbox\" name=\"Que_ID_{$info['Que_ID']}[]\" value=\"{$info['Que_Choice2']}\" /> "; echo "{$info['Que_Choice2']} <br />\n"; echo "<input type=\"checkbox\" name=\"Que_ID_{$info['Que_ID']}[]\" value=\"{$info['Que_Choice3']}\" /> "; echo "{$info['Que_Choice3']} <br />\n"; echo "<input type=\"checkbox\" name=\"Que_ID_{$info['Que_ID']}[]\" value=\"{$info['Que_Choice4']}\" /> "; echo "{$info['Que_Choice4']} <br />\n"; $counter++; } ?> <input type="submit" value="submit"/> </form> <?php mysql_close($conn); } ?> </BODY> </HTML> This is a simple example of how I think it should be working.
  3. You have "IN = (" it should just be "IN(" How about this. $sql = sprintf ("SELECT name, cover, cat, subcat, thumbsup, FROM clubs WHERE cat IN('%s', '%s', '%s', '%s', '%s') AND area = '%s' AND county = '%s' ORDER BY rand() LIMIT 5", $User['fav_1'],$User['fav_2'],$User['fav_3'],$User['fav_4'],$User['fav_5'], $User['area'], $User['county']);
  4. Did you take a look at the IN operator ? that will help clean up the statement quite considerably. Other then that I dont have another suggestion.
  5. heh been there before, if you dont understand or need more explaining dont hesitate to ask. Its the fastest way to learn.
  6. Im confused by your question. If the statement you currently have producing the result set you want and are just merely asking if there is a better way to make it neater, of are you asking how to fix the logic in the statement (because it seems to me that the logic in your question does not match the logic in your statement). Have you used the IN operator before ? If not check it out http://www.w3schools.com/sql/sql_in.asp
  7. Ill let the code speak for itself, im sure you know whats potting. I am assuming only one item, if there are more than one you would have to loop through the items in the foreach for each element. This is the full example outputting all the info, just change it to your needs <?php $doc = new DOMDocument(); $doc->loadXML(' <root> <item> <usa_smpp_host>THTTP</usa_smpp_host> <source_addr>123456</source_addr> <short_message>id:660352946 sub:001 dlvrd:001 submit date:1102081032 done date:1102081035 stat:DELIVRD err:000 text:Test SMS message 1</short_message> <dest_addr_npi>1</dest_addr_npi> </item> <item> <usa_smpp_host>THTTP</usa_smpp_host> <source_addr>987654</source_addr> <short_message>id:660352946 sub:001 dlvrd:001 submit date:1102081032 done date:1102081035 stat:DELIVRD err:000 text:Test SMS message 2</short_message> <dest_addr_npi>1</dest_addr_npi> </item> <item> <usa_smpp_host>THTTP</usa_smpp_host> <source_addr>554647</source_addr> <short_message>id:660352946 sub:001 dlvrd:001 submit date:1102081032 done date:1102081035 stat:DELIVRD err:000 text:Test SMS message 3</short_message> <dest_addr_npi>1</dest_addr_npi> </item> </root>'); $items = $doc->getElementsByTagName('item'); foreach($items as $item){ $use_smpp_host = $item->getElementsByTagName('usa_smpp_host')->item(0)->nodeValue; $source_addr = $item->getElementsByTagName('source_addr')->item(0)->nodeValue; $short_message = $item->getElementsByTagName('short_message')->item(0)->nodeValue; $part_of_short_message = substr($short_message,strpos($short_message, 'text:')+5); $dest_addr_npi = $item->getElementsByTagName('dest_addr_npi')->item(0)->nodeValue; echo $use_smpp_host."<br />"; echo $source_addr."<br />"; echo $short_message."<br />"; echo $part_of_short_message."<br />"; echo $dest_addr_npi."<br /><br />"; } ?>
  8. foreach ($episodes as $episode) { $this->Episode->create(); $this->Episode->set($episode); if($this->Episode->save()){ $count++; } } That should do the trick, the set would work by itself is the ID in the array was present, but because you have no ID present u must use the create method before issuing the save
  9. Using what gizmola said you should produce something like this: <?php $doc = new DOMDocument(); $doc->loadXML('<root><item><usa_smpp_host>THTTP</usa_smpp_host> <short_message>id:660352946 sub:001 dlvrd:001 submit date:1102081032 done date:1102081035 stat:DELIVRD err:000 text:Test SMS message</short_message> <dest_addr_npi>1</dest_addr_npi></item></root>'); $items = $doc->getElementsByTagName('short_message'); for ($i = 0; $i < $items->length; $i++) { $short_message = $items->item($i)->nodeValue; var_dump(substr($short_message,strpos($short_message, 'text:')+5)); } ?>
  10. You need to make use of the preg_match function using an expression. '/^[0-2]{2}\/[0-9]{2}\/[0-9]{4}$/' means the following: /^ = from the start of the string [0-9]{2} = look for 2 consecutive numbers between 0 and 9 (for the months) \/ = look for a "/" [0-9]{2} = look for 2 consecutive numbers between 0 and 9 (for the days) \/ = look for a "/" [0-9]{4} = look for 4 consecutive numbers between 0 and 9 (for the years) $/ = till the end of the string <?php $dateFormatToValidate = "01/01/2010"; if(preg_match('/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/', $dateFormatToValidate)){ // is valid format, but might not necessarily be a valid date do further checking // ie. could be the 30th Feb..... }else{ // not valid } ?>
  11. What happens if you do a var_dump of username and password across all the browsers then at least you can see if they are being set. It does not make sense that it would be doing what you claim its doing given the code that you have supplied.
  12. Hi xxreenaxx1, Lets break this down into steps 1,) I am assuming $sqll is the result and not the actual query string ? If not make sure you pass the function mysql_fetch_array a result and not the query. 2.) If you want to return the array $info as $info['whateverColumnThisIs'] then you need to make use of the mysql_fetch_assoc and not mysql_fetch_array. using the later would produce $info[aNumber]['whateverColumnThisIs'] 3.) Are you accepting more than one answer for each question ? if no then the checkboxes for each question should have the same name i.e. choiceForQueIdX or if you want to accept multiple answers per question you should use choiceForQueIdX[]. I dont understand why you are making use of a counter variable ? 4.) Get back yo me after making some changes to your code and answering these questions and then I can help you further
  13. Hey Chip, The problem in ur code lies in the following $monthDate->format('d') <= $monthCeiling->format('d') ; What you are making an error with is only checking the day. Its currently doing this: 01 <= 28 true fire the statement and add the new day 02 <= 28 true fire the statement and add the new day ...... 28<= 28 true fire the statement and add the new day NOW as soon as it adds the day it rolls to the new month causing $monthDate->format('d') to return 0 doing this again : 01 <= 28 true fire the statement and add the new day .. BUT because March has more than 28 days u finally get the line: 29 <= 28 False and it exits In order to fix this change this: $monthDate->format('d') <= $monthCeiling->format('d') ; to this: $monthDate->format('Y-m-d') <= $monthCeiling->format('Y-m-d') ; Hope this helps ya.
  14. I use sprintf when formulating a sql query thats my preference http://www.php.net/sprintf have a read <?php if($_SESSION['username']){ $query = sprintf("SELECT * FROM users WHERE username='%s'", $_SESSION['username']); $sql = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($sql) == 1){ $row = mysql_fetch_assoc($sql); $userlevel = $row['userlevel']; if ($userlevel == '1'){ echo"<a href='admin.php'>Admin Panel</a> // "; }else{ echo "Error: not loged in"; } } } else { echo "session not registered"; } ?> Im not sure about the line " if ($userlevel == '1'){ " because I dont know if the $userlevel variable is storing a int or string, do a var_dump($userlevel) to find this out.
  15. Suggestions: 1.) you need a where statement in your sql query in order to get one user; 2.) do a var_dump of $userlevel to see if its a string or an integer this will help you in choosing =="1" or ==1 in your if statement 3.) Are you sure you have called session_start(); on the pages that make use of this footer
  16. have you got auto increment on your forum_topics table for topic_id ?
  17. Hey As far as I know CSV files default with a seperator of a "," and not a tab as you have like ."\t" so I think its irgnoring the "\t" hence why its putting your column names in the same cell. I think tutorialized has just what you looking for http://www.tutorialized.com/view/tutorial/Export-MySQL-to-CSV-Excel/16050 In terms of exporting as CSV from mysql. I use MySQL Query browser on Ubuntu and when you get a result set back from executing a SQL statment you can export it as CSV. Hope this helps you.
  18. Ok this is how I understand your question Before I go any further lets make sure we on the same page . One last thing. Do you want the times within 5 minutes from each other or the times within 5 seconds of each other, because the examples you gave for each group are within 5 seconds from each other
  19. Hey this is my first post ! getimagesize(/dev/albumart/watershed.jpg) should be getimagesize(../dev/albumart/watershed.jpg) if the file exists that is
×
×
  • 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.