Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. [code] <?php //PHP DB connect here session_start(); mysql_connect("localhost", "*****", "*****") or die("There was an error connecting to the mysql server."); mysql_select_db("mattd_rpg"); $username=$_SESSION['username']; $password=$_SESSION['password']; $result=mysql_query("SELECT * FROM accounts WHERE username='$username' AND password='$password'"); if(mysql_num_rows($result) == 0){ die("Sorry, you are not logged in, please login again to continue playing.  If you just signed in your username and/or password may be incorrect"); }else{ $query="select * from accounts"; $rt=mysql_query($query); echo mysql_error(); while($nt=mysql_fetch_array($rt)){ if($nt[username] == $username){ echo $nt['username'].' '.$nt['money'].' '.$nt['email'].'<br>'; } } } $cash = $nt[money]; //LOGIN CHECK MUST BE ADDED $query="SELECT * FROM cars"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Cars:</center></b><br><br>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $hp=mysql_result($result,$i,"hp"); $price=mysql_result($result,$i,"price"); $owner==mysql_result($result,$i,"owner"); if(!isset($owner){ if($cash > $price){ echo "ID: <a href=\"purchase.php?buy=" . $id . "\">" . $id . "</a><br>Name:" . $name . "<br>HP:" . $hp . "<br>Sale Price:" . $price . "<br><br>"; }else{ echo "ID:" . $id . "<br>Name:" . $name . "<br>HP:" . $hp . "<br>Sale Price:" . $price . " (you can\'t afford this car)<br><br>"; } }else{ echo "<br>This car is sold.<br>";//Testing purposes only } $i++; } ?> [/code]
  2. When I check your post again I will see if I can help.  For now I am going to bed, it's one oclock in the morning, sorry I couldn't help.  Do what you can, and post back here, we'll see what we can do to fix your problem. Goodnight all.
  3. I heard of some bugs in mysqli could it have something to do with that?
  4. I personally have it like this [code]<?php if (isset($_POST['submit'])) { // validate // errorcheck // clean // process from db // update builder (entry whatever) if (mysql_query($query)) { $show = "yes"; } } ?> <?php if ($show != "yes") { ?> <!-- XHTML/CSS form right here, with submit button --> <?php } ?>[/code] Seems to just be the way I always have done it when I do same page processing.
  5. No, unfortunately it wouldn't. The reason it, something like that affects the actual php engine itself, the entire way sessions are handled, I am 90% sure that won't have any affect on it at all, however, since you can't kill the session early, destroy the session manually.    Go into where the session "file's" are on the server, and once per week, clear them all out? NEver encountered that type of problem before.
  6. Response.$Status=" Yes, I never saw anything like that in PHP before.
  7. Oh ok, well does increasing it help your initial problem?
  8. $newstring = preg_match('/get=[a-z]*\\"/', $read);?? I am not the best at regular expressions yet, far from it. Maybe that will work.  That should check for get=, then whatever might be beside it, until the ". Probably way off, but wanted to try.
  9. [code] <?php /*<--- BEGIN MY LINK HELPER CODE ---> Making modifications to this code can cause your links page to stop working. Please only make modifications where modifications are allowed.  Being that this is a free service, we do not have the resources to help you debug any changes you may have made.  If you do run into problems with this code, log into your account and download the original again. */ $OnCat = $_GET["cid"]; if ($OnCat == "") {$OnCat = "0";} //Set to Main Directory Page if (!is_numeric($OnCat)) {   Response.$Status="301 Moved Permanently";   Response.AddHeader "Location", "/"; } //You may name your links page anything you want.  But for your links page to work correctly //you must provide us with the name of your links page (without the '.php' extension). $PageName = "resources"; // change this value to match your [PageName].php links page //You may modify the following variable to change how many columns your directory displays. //By default this value is set to show 2 columns, but you may show as few as 1 column or //as many as 4. Valid values (1,2,3,4) $DirectoryCols = 2; // change this value to adjust how many columns your main directory page displays //You may modify the following variable to display your links on a single page instead of //directory style. This is a convenient way to display your links if you have fewer than 40. $ShowAsSinglePage = 0; // change this value to 1 if you want a single page, or 0 for directory $RequestPage = "http://www.mylinkhelper.com/bin/dynfetch.asp?id=7BC5F411-C799-4DD8-9D17-B398A473B76A&pagename=".$PageName."&cid=".$OnCat."&dircols=".$DirectoryCols."&single=".$ShowAsSinglePage; Set $serverXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP"); $serverXMLHTTP.$Open "GET", $RequestPage, False; $serverXMLHTTP.$Send; $htmlCode = $serverXMLHTTP.$ResponseText; $GetLinks = $htmlCode; if (instr(1,$GetLinks, "<!--ERROR") != 0) {   Response.$Status="301 Moved Permanently";   Response.AddHeader "Location", "/"; } //Get The Page Title $lLoc = instr(1,$GetLinks, "|"); if ($lLoc != 0) {   $sTitle = left($GetLinks, $lLoc - 1);   $GetLinks = right($GetLinks, strlen($GetLinks) - $lLoc); } if ($OnCat == "0") {   //This value is the title for your main directory page and can be modified   $sTitle = "Sell it yourself"; } //<--- END MY LINK HELPER CODE ---> ?> <title><?=$sTitle?></title> <?=$GetLinks?> [/code]
  10. http://devzone.zend.com/manual/view/page/function.mysqli-fetch-array.html [quote]mysqli_fetch_array() is an extended version of the mysqli_fetch_row() function. In addition to storing the data in the numeric indices of the result array, the mysqli_fetch_array() function can also store the data in associative indices, using the field names of the result set as keys.     Note: Field names returned by this function are case-sensitive.     Note: This function sets NULL fields to PHP NULL value. If two or more columns of the result have the same field names, the last column will take precedence and overwrite the earlier data. In order to access multiple columns with the same name, the numerically indexed version of the row must be used. The optional second argument resulttype is a constant indicating what type of array should be produced from the current row data. The possible values for this parameter are the constants MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH. By default the mysqli_fetch_array() function will assume MYSQLI_BOTH for this parameter. By using the MYSQLI_ASSOC constant this function will behave identically to the mysqli_fetch_assoc(), while MYSQLI_NUM will behave identically to the mysqli_fetch_row() function. The final option MYSQLI_BOTH will create a single array with the attributes of both. [/quote]
  11. Honestly, I can't help.  I never knew of session.gc_divisor or even knew it existed, I just knew of gc probability, I will have to check into that later.
  12. No, I think you misunderstood.  I don't know ANYTHING about asp, except some basic system  I had a friend come to me (non-paying project) and he was trying to find out how to get a login system.  I was able to construct him  a basic one in ASP in about 20-30 minutes.  Manually setup the database, and he already had the registration. All he needed was * user authentification (login) * logout So I built him a contact form (XHTML/CSS, and then did enough asp, to check the authentification, and create the sessions, and code for him to run throughout pages that needed password protected.  That is what I mean, I know very little about ASP, I have a friend who does a lot with asp, so I picked up bit's and ieces from him, but I am strictly PHP when it comes to server side (mostly atleast)
  13. [quote]Once you identify the urls in the text file you may find the following code useful:[/quote] Yes, that was a very nice function, I can even use that as an example later, nice work.
  14. [code]<?php function validateemail($email) { global $errorhandler; // set regular expression to test email if ($email == "") { $errorhandler .= "The email address was left blank.<br />"; } $regexemail = "^[A-Za-z0-9\._-]+@([A-Za-z0-9][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$"; if (!ereg("$regexemail", $email)) {  // test for formatting $errorhandler .= "The email address is improperly formatted<br />"; } } ?>[/code] That function will deal with your validation, now as for confirmation you can save a code in the database, pass the email address an email with a link in it, containing the code dynamically.  If that code comes back and matches the database, they are authorized, or give them a link to a pre-login area just to authorize, so you know they came from a real email address.  Also putting in a captcha will also add extra security.
  15. Your regular expressions have to match expressions $newstring = preg_match('get', $read); The pregmatch, you can't tell it to just find a word, pregmatch is for finding words that match a regular expression. something like preg_match("/$_GET[/i", "pathtofile/page.php") However, I am confused about this, because if you do $_GET['something'] it will literally look for something, so try and just check for $_GET[ then you know you have a match.
  16. In the end, it would be too wierd leaving it to the people. People put usa, Usa USA, USa US us you never know.
  17. Whether they are surrounded by php tag's, or not doesn't matter.  They can pull up those .inc files into the browser, and get information out of them directly, not only is it a valid point, but it is one of the dumbest security mistakes you could make. I use whatever.inc.php That way php still parses them, unless you custom setup your server to process .inc file's, and it's till not a good idea to get in the general habit, as it's well... Dumb.
  18. [code]<?php $mysqluser = 'user'; $mysqlpasswd = 'passwd'; $mysqlhost = 'localhost'; $connID = mysql_connect($mysqlhost, $mysqluser, $mysqlpasswd); $result = mysql_list_dbs(); echo "<p>Databases in the local MySQL server</p>\n"; echo "<p>"; while ($row = mysql_fetch_row($result)) {   echo "<br><em>$row[0]</em>\n"; } echo "</p>"; ?>[/code] First off you are trying to run, before you walk.  First get the connection, forget about list db's first. Simply do mysql_connect and mysql_select_db, using hte username/password you specified, lieke this mysql_connect("localhost", "username", "password"); mysql_select_db("db_name"); echo mysql_error(); keep it simple, then you know whether or not you are even connected in the first place. If you are, then start working with list db's, if you raen't give us the error message. If no error message returns or outputs to the page, then you are connected.
  19. I agree, I think number 2 would be a lot more organized, and usefull for that kind of purpose.
  20. [code]<?php function abrev($number) { // get length $num = strlen($number); if($num > 18) { // if 18 characters long print round($number); // round it print " Quin"; // print type (whatever it's called } elseif($num > 15) { // if 15 characters print round($number); // print rounded number print " Quad"; // print type } elseif($num > 12) { // 12 characters print round($number); // round and print number print " Til"; // followed by type } elseif($num > 9) { print round($number); print " Bil"; } elseif($num > 6) { print round($number); print " Mil"; } else { print number_format(floor($number)); } } ?>[/code]
  21. Is that specific page you keep posting B_A-Base.php and not putting out an error on a page that is included in it, or something?
  22. It could be related to your garbage collection.  If there are very few people visiting the site, and the garbage collection in the ini file is set to a very, very low percentage, it's going to be very unlikely that it emptys out the sessions at any logical time period.  If that is your problem at all.
  23. There is a much easier way, and this would be very fun to put together. Take a list of all the countries (take you 20 minutes) $countries = array(//all countries with pricing) // Example: usa=>1.00, asia=>2.00 Whatever you get the point of that part. Now when you get ready to find out, echo out only the states, in a <select> foreach your countries array here to display the countries </select> Based on which one is picked, check the array for the price of that one, adn do what you need with it.
×
×
  • 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.