Jump to content

per1os

New Members
  • Posts

    3,095
  • Joined

  • Last visited

Everything posted by per1os

  1. I am soo amazed someone did not bring up the point that you cannot check for null using the == operator. www.php.net/is_null You have to use that function to check for nulls...wow.
  2. Impossible to tell. Chances are, as long as M$ does not fall, .NET will be around but knowing M$ they may one day change the code's background completely and everything will not be backwards compatible. But yea, impossible to tell, I am not a psychic.
  3. The array I provided you with the built code will be accessed like that 0 is not an ID, 0 is equal to first place. 1 is equal to second place, they are indexes in arrays. Understand ??? So if you want to find out who was in 2nd place, simply call $my_array[1]['user_id'] To get the second place points, it is $my_array[1]['pts'] It is very simple, no need to define variables man, arrays work just the same. Than using foreach logic you can print a table of what each place a person came in, or just manually write it out using the indexes. As long as the data is formed as such $my_array = array(0 => array("pts" => 10, "user_id" => "test1", "pos" => 1), 1 => array("pts" => 16, "user_id" => "test2", "pos" => 2), 2 => array("pts" => 15, "user_id" => "test3", "pos" => 3), 3 => array("pts" => 5, "user_id" => "test4", "pos" => 4)); There is no problem. Just use my re_order code with an array formed like that and you have your answers.
  4. Does Mac allow for vmware? If so you can run windows and even linux with VMware for testing purposes.
  5. Ok now, let's try to think here. How can we test this out? <?php $selec = isset($_POST["selec"])?$_POST["selec"] . ",":''; $selec2 = isset($_POST["selec2"])?$_POST["selec2"] . ",":''; $selec3 = isset($_POST["selec3"])?$_POST["selec3"] . ",":''; $selec4 = isset($_POST["selec4"])?$_POST["selec4"] . ",":''; $selec5 = isset($_POST["selec5"])?$_POST["selec5"] . ",":''; $selec6 = isset($_POST["selec6"])?$_POST["selec6"] . ",":''; $select_cols = $selec . $selec2 . $selec3 . $selec4 . $selec5 . $selec6; $select_cols = substr($select_cols, 0, -1); echo 'Select Cols1: ' . $select_cols; ?> Does that print anything out? If yes, post it if not try this: <?php $selec = (isset($_POST["selec"]) && $_POST['selec'] != "NULL")?$_POST["selec"] . ",":''; $selec2 = (isset($_POST["selec2"]) && $_POST['selec2'] != "NULL")?$_POST["selec2"] . ",":''; $selec3 = (isset($_POST["selec3"]) && $_POST['selec3'] != "NULL")?$_POST["selec3"] . ",":''; $selec4 = (isset($_POST["selec4"]) && $_POST['selec4'] != "NULL")?$_POST["selec4"] . ",":''; $selec5 = (isset($_POST["selec5"]) && $_POST['selec5'] != "NULL")?$_POST["selec5"] . ",":''; $selec6 = (isset($_POST["selec6"]) && $_POST['selec6'] != "NULL")?$_POST["selec6"] . ",":''; $select_cols = $selec . $selec2 . $selec3 . $selec4 . $selec5 . $selec6; $select_cols = substr($select_cols, 0, -1); echo 'Select Cols2: ' . $select_cols; ?> Report back what those 2 print out. The reason it was invalid resource was the query was bad. You could add this to the mysql_query part $result = mysql_query($query) or DIE(mysql_error()); But no need to in that the error is in the select statement, so report back what that shows.
  6. www.php.net/ini_set ini_set("display_errors", "on"); error_reporting(E_ALL); Try putting those at the top and see if it reports the error.
  7. www.google.com Search for PHP Google Maps That would be the only way I would know how to do it is use the Google Maps API and customize it to suit your needs.
  8. Register_globals is probably off (the $PHP_SELF should be $_SERVER['PHP_SELF'] Make sure www.php.net/error_reporting is set to E_ALL and display_errors is on to make sure you are getting an error message if there is one.
  9. www.php.net/strtotime
  10. You have to check the hashed password in the DB vs a hashed password. MD5 is a one way hash, it cannot be decrypted. So to check you Hash up the inputed password and see if it equals the one in the DB.
  11. The problem is the W3C validator does not use COOKIES. Thus the SESSION ID is added to the page inside a hidden <input tag, which is obviously not valid. I believe you can fix this editing the php.ini config file under the sessions part, not sure what the setting is, but I think that is right. Either way it is valid, just not valid for people who do not allow cookies.
  12. $expiredate = date('Y-m-d h:s:m', time()+3600*24);
  13. Should be www.php.net/display_errors www.php.net/error_reporting It is good to be disabled in production enviroments, but for testing you want them to show all errors.
  14. <?php $selec = isset($_POST["selec"])?$_POST["selec"] . ",":''; $selec2 = isset($_POST["selec2"])?$_POST["selec2"] . ",":''; $selec3 = isset($_POST["selec3"])?$_POST["selec3"] . ",":''; $selec4 = isset($_POST["selec4"])?$_POST["selec4"] . ",":''; $selec5 = isset($_POST["selec5"])?$_POST["selec5"] . ",":''; $selec6 = isset($_POST["selec6"])?$_POST["selec6"] . ",":''; $select_cols = $selec . $selec2 . $selec3 . $selec4 . $selec5 . $selec6; $select_cols = substr($select_cols, 0, -1); $db = mysql_pconnect("localhost",$_SESSION["login"],$_SESSION["password"]); $query = " SELECT " .$select_cols . " FROM " .$_SESSION["nomtab"]. " "; $result = mysql_query($query); echo "<table bgcolor=\"#DDDDDD\" align=center style=\"border:2px outset black\">"; for ($i = 0; $i < mysql_num_fields($result); $i++) { print "<th>".mysql_field_name($result, $i)."</th>\n"; } while ($registro = mysql_fetch_row($result)) { echo "<tr>"; foreach($registro as $clave) { echo "<td bgcolor=\"#BBBBBB\"style=\"border:2px groove black\" align=\"center\">",$clave,"</td>"; } } echo "</tr></table>"; } Why not only pass in the columns you want out of the query? This should suffice.
  15. What format is your timestamp in? Is it a unix timestamp? If not look into www.php.net/strtotime The issue lies within the timestamp, not the date function.
  16. class eventList { var $stack = array(); var $tagname=""; function create($filename) { if (! ($xmlparser = xml_parser_create()) ) { die ("Cannot create parser"); } function start_tag($parser, $name, $attribs) { global $tagname; $tagname = $name; } function end_tag($parser, $name) { } function tag_contents($parser, $data) { global $tagname; global $stack; $stack[$tagname]=$data; } xml_set_element_handler($xmlparser, "start_tag", "end_tag"); xml_set_character_data_handler($xmlparser, "tag_contents"); if (!($fp = fopen($filename, "r"))) { die("cannot open ".$filename); } while ($data = fread($fp, 4096)) { $data=eregi_replace(">"."[[:space:]]+"."<","><",$data); if (!xml_parse($xmlparser, $data, feof($fp))) { $reason = xml_error_string(xml_get_error_code($xmlparser)); $reason .= xml_get_current_line_number($xmlparser); die($reason); } } xml_parser_free($xmlparser); } } $event1=new eventList(); $event1->create("http://www.example.com/rss.xml"); ?> Parse error for one, turn on display_errors and error_reporting to E_ALL and report any more errors.
  17. Don't use the magic quotes, they do no good. Especially since they are being depreciated. <?php if((isset($act)) && ($act=="action")){ $dates=date("Y-m-d"); echo "<div class=text>Data successfully updated on ". $dates. "<br> please wait while your browser redirects you to the main admin page.....</div>"; $sql=mysql_query("update announcement set date='$dates', title='" . mysql_real_escape_string($announce1) . "', text='" . mysql_real_escape_string($detail1) . "', title1='" . mysql_real_escape_string($announce2) . "', text1='" . mysql_real_escape_string($detail2) . "', title2='" . mysql_real_escape_string($announce3) . "', text2='" . mysql_real_escape_string($detail3) . "'"); ?> <script language="javascript"> setTimeout('test()',2000); function test(){ window.location.href="../index.php" } </script> <?php }else{ echo 'You are not allowed here'; ?> <script language="javascript"> setTimeout('test()',1500); function test(){ window.location.href="index.php" } </script> <?php } ?> That should solve your problem. The first post referenced the right function. www.php.net/mysql_real_escape_string I suggest you read up on it.
  18. Alright let's think about this. Why don't we house the position as an item in the array? Interesting... $my_array = array(0 => array("pts" => 10, "user_id" => "test1", "pos" => 1), 1 => array("pts" => 16, "user_id" => "test2", "pos" => 2), 2 => array("pts" => 15, "user_id" => "test3", "pos" => 3), 3 => array("pts" => 5, "user_id" => "test4", "pos" => 4)); That way you know what position they were in, and their userid, with how many points they made. With a re-order of the array we get them filtered by who won/lost right? So with that logic, $my_array[0]['user_id'] will print to use the first positions user id. $my_array[2]['pts'] would print to us third places points. $my_array[1]['pos'] will tell us what position 2nd place was in. No need to assign them to variables, the array will do the trick without the hassle and for unlimited users.
  19. All you need is less than 20 MB's of disk space for PHP to run WITH an editor. .NET you have to have the whole shabang, Windows XP Pro or Server 2003, $$$, .NET Studio $$$$$ To host it you have to find a host $$$$$$$ With PHP MySQL = FREE; PHP = FREE; Linux = FREE; Apache = FREE. Notepad ++ = FREE or Eclipse = FREE. Really you can get away for a $10/month host with PHP or even host your own server right off your box. Finally PHP = Open Source, and well .NET = Micro$oft. Who would you trust more ???
  20. What is the above issue? You never really stated a problem.
  21. That database design needs some serious work. Why not have a separate table with a date or a round id associated with it. IE: create table round ( roundid int(11) NOT NULL auto_increment, roundtitle varchar(50) NOT NULL, Primary Key (roundid) ); create table user_rounds ( user_round_id INT(11) NOT NULL auto_increment, roundid INT(11) NOT NULL, userid INT(11) NOT NULL, Priamry Key (user_round_id) ); create table round_results ( round_results_id INT(11) NOT NULL auto_increment, place tinyint(1) NOT NULL, primary key(round_results_id) ); create table user_round_results ( user_round_results_id INT(11) NOT NULL auto_increment, user_round_id INT(11) NOT NULL, round_results INT(11) NOT NULL, Primary Key (user_round_results_id) ); That would be the ideal way to do it =) Normalization is wonderful. Anyhow, I wouldn't want to do it in separate columns inefficient, just thought I would throw this thought out there. <?php /* Takes in an array by reference and re-orders the array to be sorted by points. */ function re_order(&$array) { $rows = array(); $rows = $array; $array = array(); $i=1; $sort_ar = array(); foreach ($rows as $old_key => $points) { foreach ($points as $key => $val) { if ($key == 'p' . $i . '_pts') { $sort_ar[$old_key] = $val; } } $i++; } arsort($sort_ar); // should sort by points $i=0; foreach ($sort_ar as $oldkey => $sorted) { $array[$i++] = $rows[$oldkey]; } return true; } $my_array = array(0 => array("p1_pts" => 10, "p1_id" => "test1"), 1 => array("p2_pts" => 16, "p2_id" => "test2"), 2 => array("p3_pts" => 15, "p3_id" => "test3"), 3 => array("p4_pts" => 5, "p4_id" => "test4")); re_order($my_array); echo '<pre>', print_r($my_array); ?> There is one way to do it for any amount of users. The new array is ordered correctly just look through the array with www.php.net/foreach to get the first second etc. Anyhow I would look into a database redesign.
  22. $checkemail=mysql_query("SELECT email FROM GCuser WHERE email='$emailx' LIMIT 1") OR DIE (mysql_error()); report the error.
  23. <?php $checkemail=mysql_query("SELECT email FROM GCuser WHERE email='$emailx' LIMIT 1"); if(mysql_num_rows($checkemail) == 1){ //Everything is dandy }else{ //die} ?>
  24. www.php.net/file www.php.net/file_get_contents It's called web parsing. As far as there being another script out there, I am sure there is. You just have to search a little. If not it would not be too hard to create. Just gotta parse the results.
×
×
  • 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.