Ninjakreborn
Members-
Posts
3,922 -
Joined
-
Last visited
Everything posted by Ninjakreborn
-
Really tired, up late trying to answer questions, so that may have been a pathetic attempt.
-
<?php function abrev($number) { $num = strlen($number); if($num > 18) { print round($number); print substr($number, -18, strpos($number, '0')); print " Quin"; } elseif($num > 15) { print round($number); print substr($number, -15, strpos($number, '0')); print " Quad"; } elseif($num > 12) { print round($number); print substr($number, -12, strpos($number, '0')); print " Til"; } elseif($num > 9) { print round($number); print substr($number, -9, strpos($number, '0')); print " Bil"; } elseif($num > 6) { print round($number); print substr($number, -6, strpos($number, '0')); print " Mil"; } else { print number_format(floor($number)); } } ?>
-
See that is the point, http referrer pulls the entire url they came from. If you want to go back to the last page on your site, use split on http referrer, to get the exact folder location you want to send them to. It's also not always 100% accurate. I saw your last post, what page is it sending them to. Echo here EXACTLY what the from field is outputting, and show th eoutput on the page, does it give you an error. If it comes up with a blank page, it's an error, if it's sending you somewhere specific, where as opposed to where is it suppose to send you.
-
[quote]<?php Check User Script session_start();[/quote] Looking it that, it's probably telling you headers already sent. You can't have a space between the <?php and hte session_start. Fix that, adn try it again.
-
Purchase page (math and/or database problem)
Ninjakreborn replied to mattd8752's topic in PHP Coding Help
[code] <?php 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 no longer logged in, please login again to continue playing."); }else{ while($r=mysql_fetch_assoc($result)){ //This is where you would define all your resources, buildings, units, etc. $cash=$r['money']; } } if(isset($_GET['buy'])){ $buying = $_GET['buy']; if($buying == "1"){ $money_spent == "500"; if($money_spent > $cash){ echo "Not Enough Cash"; }else{ $newmoney=$cash-$money_spent; mysql_query("INSERT INTO cars (name, hp, owner) VALUES('Starter Car', '50', $username ) "); mysql_query("UPDATE accounts SET money='$newmoney' WHERE username='$username' AND password='$password'"); //possibly no ; next line might need single quotes echo "Starter Car has been purchased for $500. (You have $" . $newmoney . " left)"; } } if($_GET['buy'] == "2"){ $money_spent == "25000"; if($money_spent > $cash){ echo "Not Enough Cash"; }else{ $newmoney=$cash-$money_spent; mysql_query("INSERT INTO cars (name, hp, owner) VALUES('92 Mustang GT', '225', $username ) "); //http://www.mustanggt.org/92gt.htm mysql_query("UPDATE accounts SET money='$newmoney' WHERE username='$username' AND password='$password'"); //possibly no ; next line might need single quotes echo "92 Mustang GT has been purchased for $25000. (You have $" . $newmoney . " left)"; } } if($_GET['buy'] == "3"){ // INCOMPLETE PAST HERE $money_spent == "5000"; if($money_spent > $cash){ echo "Not Enough Cash"; }else{ $newmoney=$cash-$money_spent; mysql_query("INSERT INTO cars (name, hp, owner) VALUES('1995 Jeta III', '115', $username ) "); //http://www.internetautoguide.com/car-specifications/09-int/1995/volkswagen/jetta-iii/index.html mysql_query("UPDATE accounts SET money='$newmoney' WHERE username='$username' AND password='$password'"); //possibly no ; next line might need single quotes echo "1995 Jeta III has been purchased for $5000. (You have $" . $newmoney . " left)"; } } } ?> [/code] \ Looking at this more heavily, it's going to be very hard to debug this code, NEVER pass queries straight into sql. Trap them into variables, clean them, then pass them in, it's also easier to find problems, and hunt down problems that way. Also your calculations seem to complexe for something so simple, try toning it down a bit, see if you can find a simpler solution. I don't think it's recieving that value from teh database $r['money']; or whatever it was, I Don't think it's even populating that variable at all. The cash variable, I am almost sure it's not reading that one, test that variable that it's getting the value, or use mysql_error to test if the query is even being ran. Rewrite some of that, to allow you to hunt down the problem better. Also it looks like you are not doing anything, there are 2 things you need to NOT do. 1. Make sure the passwords are encrypted 2. Make sure you are NOT passing that password (encrypted or not) around as a session with the username. You have no need to carry that around, once they are logged in, they are logged in. You don't have to double verify it, that is not safe. Passing those variables straight into those queries is not a good idea, I think you should rewrite the whole thing, with my points in mind, I will bookmark this, if you don't have it figured out tomorrow or monday, I will help you figure out what is going on, once it's rewritten and easier to read. -
How to handle the dates greater than "2057-12-31"
Ninjakreborn replied to jeeva's topic in PHP Coding Help
Nice function. -
Yes, there is something to change the first letter to capital, or non-capital. Not sure what it was called, if not regular expressions.
-
Check the from variable make sure it is sending information, also make sure that it has header('Location:'.$from); rewritten like header("Location: $from"); That is seemingly more efficient for me, give it a try. Hope that helps.
-
Unix is great, I love both unix, and linux. What is stopping you from it, if you don't have the know you might have to hire someone, or find a quick insert script you can modify, have it formulate that errors, and put them in a database. Whsy kind of errors?
-
For example, you had a table, with a column Table name - users fields id username password firstname lastname accesslevel The access level is set to 1, for all user's. You redo your entire database structure so now you want all access level's to change to 1 There are 2 ways to do this UPDATE users SET accesslevel = 2;"; run that through, it will update them ALL to 2. That is for that kind of situation, for another, if you have a build a bunch of "different" updates, and you are not sure which one's are which. Then set up 2 arrays, one with column name's, one's with the values they need like $table_names = array("user"=>"dave", "user2"=>"mike", "user3"=>"John"); // excuse if it's not proper, right now, I am tired, and not thinking much, just trying to help some people tonight before going to bed. then run it through a foreach foreach($table_names as $k=>$v) { $update = "UPDATE tablename $k = $v;"; $query = mysql_query($update); } Shitty example, but hopefully you get the point. This will take heavy modification, because last time I Tried to do this, it failed miserably, after 6 hours worth of fighting with it, I finally got it to work, but I don't remember "Where" I did this at, or I could provide you with the code. Unfortunately, I don't have it right now, so hopefully atleast that will point you in the right direction.
-
Purchase page (math and/or database problem)
Ninjakreborn replied to mattd8752's topic in PHP Coding Help
[quote]Please PM the answer to this as I am logging off if you can.[/quote]\ That's not the way the forum work's, it's meant to help everyone as a whole. As I said, if it's not reading it 1. Check all the variables, make sure they are recieving there respective values (echo them) 2. Echo out the queries themselves, see what the string holds, so you can tell if the values are making it into teh query itself If both of those work, check the calculations to make sure they are working right It sounds like it's either 1 or 2, and they are both very easy to check, echo the variables, and the queries. -
Well, maybe not If you wanted to do it instantly, (low level), use javascript and cookies (sessions) Or if you wanted them to really have long distance editing capabiliteis (They had there own pages, you wanted them having permanent control over), save the settings in a database, then let php fetch those settings based on there ip when they return
-
Purchase page (math and/or database problem)
Ninjakreborn replied to mattd8752's topic in PHP Coding Help
I don't see anything wrong with the script itself, it does what you tell it to do. Is there something at some point wrong with teh calculations, I am not too good at math., eEcho each of your variables, and then check to see what they are, and do your calculations on paper, to make sure they are doing what they should be doing. -
I don't like the situation the code is set in, so I can't help with that part. But I can point you in the right direciton, you want to build your query have each table you need updated in an array, and each thing updating it in an array, and run it through a foreach loop. Use count to get the total number, so it foreaches through the proper amount.
-
No it would be <link rel="stylesheet" type='text/css" href="/path/to/css.css" /> /path/to/css.css = The relative url path to your css file. It has nothing to do with CSS code UNLESS you are outputting the css with php dynamically for some reason (A user based cms, or something similar.
-
What's wrong with that, it's a very good function. I think use it, if it's not doing what you want, make some modifications. Where is your current function failing, or not doing what you want?
-
XHTML/CSS, the styling and coloring would have nothing to do with PHP unless you were simply outputting different CSS styles with php. The entire thing that would control the style's is CSS. in an external stylesheet, to the style you want to add a background color add background-color:#CCCCCC; or whatever other hex code for whatever other color you wanted, the background would change to that color.
-
Just instead of sending an email with the errors, log them in a database. Something like errors (tablename) id - identifies the error number so you always have it description - description of the error writern during programming errorcode- if your specific errors are based on error codes just keep track of that In 30 minutes you could have an admin panel to add/edit/delete, query and report on the information, without taking too much time to develop on it, or you could hire someone if you are not a programmer, to do it for you in a relatively short and cheap period of time.
-
unless I misunderstood, I would answer like this Take all teh color's of hexes, and put them in a giant array, color name, hex number. Then create a program to test the color, if it's a dark color generally white would look good, if it's a light color white would look good. Then during testing you can take note of what looks bad and what doesn't and build onto the knowledge base overtime to make it smarter and smarter at discerning colors.
-
Look's much better than it did in my opinion, but 2 things 1. The advertisement is still too big on the top 2. There are no line's, borders or anything splitting up the elements on the page.
-
Review my site. Bring it on. Thank you.
Ninjakreborn replied to erichar11's topic in Website Critique
What I meant by broken was You had the boxes like this [ ][ ][ ][ ][ ] it looked like you wanted to left side of the box, to look like it was faded behind the right side of the previous box. What happens is, the first 3 look like that, hten the last 2-3 look like they are on the same level, it detracts (for me) a little from the navigation. If that makes any sense, if not then I am not quite sure if I can explain it well enough to pass my point across. -
* coloring's nice * layout is nice * Minor Annoyance: It starts out a long layout (left to right), then has a tall box, then log again, it looks to sporadic. * Major Annoyances: done in tables, not validated. Other than that it looks good.
-
* when you click on it erases the other instead of adding htem together. If you click bold, then italics, it replaces the other bold with italics. That is only when no text is entered, it is a very good editor, or could be over time. I think it needs a better layout (maybe move the output over some), and it could use some more features before being made a standalone application. Like bullet's and some other stuff, but so far it's coming along quite well.
-
Actually he is right. Asp is very, very simple after you know php. I was able to pick up asp in about 30 minutes and built an entire login membership system (no errors, just coded it, and it worked). No problems except checking up the syntax so if you know php, doing asp isn't that hard, I just wouldn't take the time to memorize syntax.
-
each one parse differently, but the source remain the same, ie source is the same as firefox source. I don't understand the full nature of your problem to help any more than that.