Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. I think that s represents the space if you do \ds the above function will work fine, but without the s it does not.
  2. Dreamweaver is great for designing pages, but I have never used it for PHP coding, but knowing how dreamweaver works I probably wouldn't recommend it. Dreamweaver is all about just getting it running and not caring if someone can actually read through stuff. My 2 cents anyhow, or search if dreamweaver has a php plugin for proper indents etc.
  3. If you have a .htaccess make sure that is not modifying the session data either, as that can overwrite the php.ini settings. That is if you have one.
  4. Just a side note, I would also use indentation in my code. It makes it soo much easier to read and debug. As you have it there you have like 5 } in a row and no one can tell which goes with what unless they do a painful trace back. If you are just using notepad, I would find a program that syntax highlights as well, such as notepad ++. It makes it a ton easier to code with.
  5. Well one note, if the browser is closed the session ends. If you closed the browser and went back to the page, that is the reason why. As for why it would not work, do a phpinfo(); and check that Session Support enabled Cause it may not be enabled. Other than that I am not sure what would cause it.
  6. Just reverse the logic: $i=1; $cnt = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { if ($i == $cnt) { continue; // dont print the first id } echo $row['id']; $i++; } Should do the trick.
  7. Could be a server issue, could be you did not allow cookies. I do not know. Does that still happen, or was that just one time?
  8. They should be passed through anways. The above code just forces a cookie to handle the sessid instead of the query_string. Just remember to call session_start at the top of any page using sessions and make sure it is called before any output is echoed to the browser.
  9. Maybe try this for the if statement: $roll_no = isset($_POST['roll_no'])?trim($_POST['roll_no']):null; if (!is_null($roll_no) && !empty($roll_no)) { And see if it still executes.
  10. In your sql query do an order by ID, then the following should help you with the logic $i=0; while ($row = mysql_fetch_assoc($result)) { if ($i == 0) { $i++; continue; // dont print the first id } echo $row['id']; } Hope that helps ya.
  11. It just means you need to adjust your logic: if (mysql_num_rows($rP) > 0) { $aP = mysql_fetch_array($rP); } That way if there are rows to return it does, else it does not throw an error and die. Really you should not have a die on the fetch array portion, just the query portion. The above logic is not needed unless you want it, just remove the die and it will return an empty array I believe or false.
  12. It is set in the cookie. http://webscripts.softpedia.com/script/Snippets/disable-php-sessid-in-URL-3448.html Will help you to disable it. If that is disable the default will be to use cookies to store the sessionid. If the user does not have cookies enable it will resort to the url. Using the cookies you only need to call session_start and it will automatically get the sessionid from the set cookie and start that previous session.
  13. Be more descritive next time. I take it you want to check that $roll_no actually contains a value? $roll_no = isset($_POST['roll_no'])?$_POST['roll_no']:null; if (!is_null($roll_no)) { // do processing here. }
  14. // CHECK TO SEE IF THE USERNAME/PASSWORD ARE IN THE DATABASE $qP = "SELECT `ADMIN_USERNAME`,`ADMIN_PASSWORD` FROM `cmp_admins` WHERE `ADMIN_USERNAME`='$userName' AND `ADMIN_PASSWORD`='$encPass' LIMIT 1"; print $qP . "<br />"; $rP = mysql_query($qP) or die (mysql_error()); print $qP . "<br />" . mysql_error(); $aP = mysql_fetch_array($rP) or die (mysql_error()); Chances are the die is hitting, see what the $qP displays, if you see it twice it dies at the fetch_array. See how the sql statement is formatted and see if you cannot see the error message.
  15. Just a side note here. error_reporting will not do much if display_errors is off. error_reporting(E_ALL); ini_set("display_errors", 1); I generally always use those in combination. I looked at the code and it looks alright, but I will keep looking to see if I see anything. Generally when that happens I tend to do echos such as "echo 'HERE1'; at parts of the script to see where it stops working and just iterate the number after here. That will take you to the source and help you figure out what if/loop etc is causing the problem.
  16. You may want to see if header Has this functionality. Where on the script that redirects set the header of the referrer. I think that would work, but not sure.
  17. dom Take a look at the PHP DOM, I think that is what you would want. An example from the DOMDocument comments <?php function xml2array($xml) { $domDocument = new DOMDocument; $domDocument->loadXML($xml); $domXPath = new DOMXPath($domDocument); $array = array(); foreach ($domXPath->query('//key') as $keyDOM) { $id = $keyDOM->getAttribute('id'); $value = $keyDOM->hasAttribute('value') ? $keyDOM->getAttribute('value') : trim($keyDOM->textContent); if (array_key_exists($id, $array)) { if (is_array($array[$id])) { $array[$id][] = $value; } else { $array[$id] = array($array[$id]); $array[$id][] = $value; } } else { $array[$id] = $value; } } return $array; } ?>
  18. Are you sure you have a database called sex1800_phpresult ?
  19. scandir foreach Hope those will get you started.
  20. How about setting a session variable? Then check if that session variable isset, IE: $_SESSION['camefromme'] = true; So if that is set then you know it came from your site and not the other, than after the check unset that variable incase they decide to leave and comeback without closing the browser.
  21. One way to do it: <?php // sql connection above $sql = "SELECT * FROM tbl_name ORDER BY name"; $res = mysql_query($sql); while ($row = mysql_fetch_assoc($res)) { if ($row['name'] == $oldName) continue; $delSQL = "DELETE FROM tbl_name WHERE id = " . $row['id']; mysql_query($delSQL); $newSQL = "INSERT INTO tbl_name (col1, col2, col3) VALUES ('" . $row['id'] . "', '" . $row['name'] . "', '" . $row['happy'] . "')"; mysql_query($newSQL); echo $newSQL; $oldName = $row['name']; } ?> One word of warning, I would do a run through it with just the insert part and make sure the query is getting formatted correctly. I would also back up the current table data, just incase everything gets deleted and nothing gets re-populated. Replace $row['name'] with an identifier of how you can if it is a duplicate. But as a stated above, backing up your data is a must as this could delete all your rows etc and then your SOL.
  22. function generatePass ($length) { $alreadyExists = true; while ($alreadyExists) { $password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyz"; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); $password .= $char; $i++; } $sql = "SELECT random FROM tbl_name WHERE random = '" . $password . "'; $res = mysql_query($sql); if (mysql_num_rows($res) == 0) { $alreadyExists = false; } } return $password; } Hope that helps. You will have to modify the SQL and make sure you do have a SQL connection for that work.
  23. The problem is in the foreach. If you know which row number it is being returned I would do this: <?php ///etccccc while($row = mysql_fetch_row($exp)) { $line = ''; $cnt = count($row); for ($i=4; $i>$cnt; $i++) { $selections[] = $row[$i]; unset($row[$i]); } $selection = implode(", ", $selections); $row[4] = $selection; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = ",\t"; } else { $value = str_replace('"', '""', $value); And a side note, indenting is your friend!
  24. <?php if(isset($_POST['delete'])) { $DelID = isset($_POST['DelID'])?$_POST['DelID']:0; if ($DelID != 0) { $sDELQUERY = "DELETE * FROM tblComment WHERE sCommentID=$DelID"; $adoConnection->Execute( $sDELQUERY ); } } ?> Give that a try and see.
  25. You need your DB connection inside the function, than use a while loop, while alreadyExists is true continue, set alreadyExists to false when you know it is not in your DB. Hope that logic helps to get you going.
×
×
  • 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.