Jump to content

KillerBeeZ

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

About KillerBeeZ

  • Birthday 06/03/1977

Contact Methods

  • Website URL
    http://www.ctlinx.com

Profile Information

  • Gender
    Male
  • Location
    Live Oak Florida

KillerBeeZ's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thank you so much, that was perfect and you my friend are a genius with php oh and Freelance, the path and file name are all saved as one big string in sql as the people entering in the data upload the image, then just copy the path in their browsers address bar to enter into the database.
  2. is there a function to take a part of a string and add to it? for example, in my database I have the addresses stored for several images. I'm making a racing game that shows these images for the cars while racing. The problem is resizing the images in html only shrinks the physical dimensions but the image still takes the same amount of space, like 200k or something depending on the image. I have thumbnails for all of the images and the name of the file is exactly the same as the original except with a TN- added to the front of the file name. I could add that fairly easily except that the folders are different for the images So, what I'd like to do is to add a TN- in the middle of a string. <div align=\"center\"><img src=\"$car1image[0]\" height=\"50\"></div> $car1image[0] = "http://www.ctlinx.com/piwigo/upload/2012/05/24/20120524171350684011fb.jpg" will need to be changed to $car1image[0] = "http://www.ctlinx.com/piwigo/upload/2012/05/24/TN-20120524171350684011fb.jpg" (these addresses are not static, they are dynamic, I made them static here as an example) Is this possible? Is there a better way to resize images on the fly? or do I have to add all the thumbnails to the database too (keeping in mind there are at present over 3000 images and that's just Dodge, Chevy and a few Audi's)?
  3. it took me a while to figure it out but I got it, thank you very much you are extremely helpful
  4. http://www.ctlinx.com/org/panprix/races/raceengine.php this is the test page I made to debug this issue... if that helps at all. The race will start when the pending race hits the current time and the page will refresh every minute (or refresh manually) The images of the cars are entered manually but you will see the (resource id #**) error in the line below the pending races and above the current race (if a current race is active) will look like "Resource id #19 , 2000 , Dodge , Grand Caravan SE fwd " when a race is current or "Resource id #13 , , , " when its not active. I'd really like to find the answer to this, I know you guys (and gals) are busy and have better things to do than help others solve their problems, but I'd be very grateful for any insight you can offer.
  5. I'll try This is the section of the race engine file in question <table width="100%" border="1" cellspacing="2" cellpadding="2"> <tr> <th><div align="center">Rank</div></th> <th><div align="center">Image</div></th> <th>Player, Car, Score</th> </tr> <tr> <? $qcar1image = "SELECT image FROM cars WHERE year = '$a1yr' AND make = '$a1mk' AND model = '$a1md'"; $qcar2image = "SELECT image FROM cars WHERE year = '$a2yr' AND make = '$a2mk' AND model = '$a2md'"; $qcar3image = "SELECT image FROM cars WHERE year = '$a3yr' AND make = '$a3mk' AND model = '$a3md'"; $qcar4image = "SELECT image FROM cars WHERE year = '$a4yr' AND make = '$a4mk' AND model = '$a4md'"; $car1image = mysql_query($qcar1image); $car2image = mysql_query($qcar2image); $car3image = mysql_query($qcar3image); $car4image = mysql_query($qcar4image); $ranks = array("<div align=\"center\"><img src=\"$car1image\"width=\"50\" height=\"50\"></div></p></td><td>$car1player in the $a1yr $a1mk $a1md" => "$residual1", "<div align=\"center\"><img src=\"$car2image\"width=\"50\" height=\"50\"></div></p></td><td>$car2player in the $a2yr $a2mk $a2md" => "$residual2", "<div align=\"center\"><img src=\"$car3image\"width=\"50\" height=\"50\"></div></p></td><td>$car3player in the $a3yr $a3mk $a3md" => "$residual3", "<div align=\"center\"><img src=\"$car4image\"width=\"50\" height=\"50\"></div></p></td><td>$car4player in the $a4yr $a4mk $a4md" => "$residual4"); arsort($ranks); $ri = 1; foreach ($ranks as $key => $val) { echo "</tr><td><div align=\"center\">$ri</div></td>"; echo "<td>$key = $val\n</td><tr>"; $ri++; } mysql_close(); ?> </tr> </table> I know there is a better way to get the sql data than to use 4 different queries, but this is only a draft while I learn php. My native language is C# and never got around to working with sql. I will clean up the code once it is working properly. This is the row from the sql database I'm trying to call (I apologize, I will likely never get it to line up correctly on here) year make model class cost image description bodytrim horsepower topspeed cd height width weight hwympg citympg pow han acc brk acnt 2003 Dodge Grand Caravan SE fwd D 4550 http://www.ctlinx.com/piwigo/upload/2012/05/24/201... a mini van with a good bit of acceleration and pow... Van 180 109 0.35 68.9 78.6 3991 24 17 50 30 65 14 KillerBeeZ This is the section that calls the data from yet another sql database that is needed in order to know which car to select... $co = 0; $car1player = mysql_result($resultr,$co,"player"); $car1vin = mysql_result($resultr,$co,"vin"); $car1stat_pow = mysql_result($resultr,$co,"totpow"); $car1stat_han = mysql_result($resultr,$co,"tothan"); $car1stat_acc = mysql_result($resultr,$co,"totacc"); $car1stat_brk = mysql_result($resultr,$co,"totbrk"); $a1yr = mysql_result($resultr,$co,"year"); $a1mk = mysql_result($resultr,$co,"make"); $a1md = mysql_result($resultr,$co,"model"); all of that gets its data from this row in sql player vin year make model engine-vin trans-vin weightmod-vin aero-vin totpow tothan totacc totbrk KillerBeeZ 1234567890 2000 Dodge Grand Caravan SE fwd oem12345 oem12345 oem12345 12345 50 30 87 14 If I forgot something just let me know and I'll add it too. There really is a lot of code to go over
  6. there are over 800 lines of code in several files... what parts do you think I should post?
  7. took the - out of the image, tested it and its the same, so thats not it... any ideas?
  8. ok it might be that the url has a - in it. I need to leave it like it is however, is there a way in php to call that url as it is without any kind of need for escape or changing the images? http://www.ctlinx.com/piwigo/upload/2012/05/24/20120524171350-684011fb.jpg I cannot ask the people entering in the data to use a \ in the address, they won't understand in C# you could do this with @ I think
  9. I saw that last night but the board was down or something and couldn't post. I just removed the - in the whole darn thing. Curious though, could I also just use an escape \? such as $residual1 = mysql_result($resultd,0,"s1\-1st"); Also, on another note, I'm trying to insert an image where the url is stored in sql. $qcar1image = "SELECT image FROM cars WHERE year = '$a1yr' AND make = '$a1mk' AND model = '$a1md'"; $car1image = mysql_query($qcar1image); getting that old Resource id #13 and such errors. All the variables are filled with the correct data so it makes me think I have a syntax error
  10. please help me understand why that one has to be like that but this one works just fine? $querytimer1 = "UPDATE races SET rtimer = '$rtimer' WHERE track = '$Track' ";
  11. been looking over this script, which is part of a larger script, and so far I can't figure out why it is not saving the data to the sql database. It seems like some small stupid thing I'm overlooking but if so I cannot seem to find it... it should take 4 values, manipulate them, then average them out and save the result to sql, that result (there are 10 passes to this script) is then added upon itself until in the end there are a few fairly large numbers. This is for a racing game $residual1 2 3 and 4 all do end up with data, the problem is its not stacking due to the fact that its not saving to sql <? $residual1 = mysql_result($resultd,0,"s1-1st"); $residual2 = mysql_result($resultd,0,"s1-2nd"); $residual3 = mysql_result($resultd,0,"s1-3rd"); $residual4 = mysql_result($resultd,0,"s1-4th"); $powcal1 = ($car1stat_pow - (($tpow) - 15) + rand(1, 30)); $hancal1 = ($car1stat_han - (($than) - 15) + rand(1, 30)); $acccal1 = ($car1stat_acc - (($tacc) - 15) + rand(1, 30)); $brkcal1 = ($car1stat_brk - (($tbrk) - 15) + rand(1, 30)); $totcal1 = (($powcal1 + $hancal1 + $acccal1 + $brkcal1) / 4); $residual1 = ($residual1 + $totcal1); $resid1 = "UPDATE racedata SET s1-1st = '$residual1' "; mysql_query($resid1); $powcal2 = ($car2stat_pow - (($tpow) - 15) + rand(1, 30)); $hancal2 = ($car2stat_han - (($than) - 15) + rand(1, 30)); $acccal2 = ($car2stat_acc - (($tacc) - 15) + rand(1, 30)); $brkcal2 = ($car2stat_brk - (($tbrk) - 15) + rand(1, 30)); $totcal2 = (($powcal2 + $hancal2 + $acccal2 + $brkcal2) / 4); $residual2 = ($residual2 + $totcal2); $resid2 = "UPDATE racedata SET s1-2nd = '$residual2' "; mysql_query($resid2); $powcal3 = ($car3stat_pow - (($tpow) - 15) + rand(1, 30)); $hancal3 = ($car3stat_han - (($than) - 15) + rand(1, 30)); $acccal3 = ($car3stat_acc - (($tacc) - 15) + rand(1, 30)); $brkcal3 = ($car3stat_brk - (($tbrk) - 15) + rand(1, 30)); $totcal3 = (($powcal3 + $hancal3 + $acccal3 + $brkcal3) / 4); $residual3 = ($residual3 + $totcal3); $resid3 = "UPDATE racedata SET s1-3rd = '$residual3' "; mysql_query($resid3); $powcal4 = ($car4stat_pow - (($tpow) - 15) + rand(1, 30)); $hancal4 = ($car4stat_han - (($than) - 15) + rand(1, 30)); $acccal4 = ($car4stat_acc - (($tacc) - 15) + rand(1, 30)); $brkcal4 = ($car4stat_brk - (($tbrk) - 15) + rand(1, 30)); $totcal4 = (($powcal4 + $hancal4 + $acccal4 + $brkcal4) / 4); $residual4 = ($residual4 + $totcal4); $resid4 = "UPDATE racedata SET s1-4th = '$residual4' "; mysql_query($resid4); ?>
  12. thank you. I have found this board is a lot more helpful than other boards of this type.
  13. that did the trick, thank you so much. I was unaware that you could do any calculations in sql, I thought it was just a database. I have much to learn. I have just one more question... After looking thoroughly on amazon for php/sql books it seems they all have some bad reviews for one reason or another. If you were to recommend a book on php and/or sql to someone with prior C# experience but little php and no sql knowledge, what book(s) would you recommend?
  14. thank you for helping, I tried that but it is doing the same thing, it sets the date in sql to all 0's Track Race Started? Race Start Time test Race Started 0000-00-00 00:00:00 test2 Race Started 0000-00-00 00:00:00 test3 not started yet 2012-05-25 00:07:00 new code... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Car Entered</title> <style type="text/css"> <!-- .style1 {color: #003300} .style2 {color: #990000} --> </style> </head> <body> <?php include '../admin/php/connect.php'; mysql_connect("localhost",$user,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM races"; $result=mysql_query($query); $num=mysql_num_rows($result); $query2="SELECT * FROM account"; $result2=mysql_query($query2); $num2=mysql_num_rows($result2); $query3="SELECT * FROM tracks"; $result3=mysql_query($query3); $num3=mysql_num_rows($result3); $i=0; $datetimeNOW = date("Y-m-d H:i:s "); ?> <span class="style1">Current date/Time:</span> <? echo $datetimeNOW; ?> <table width="100%"border="1" cellspacing="2" cellpadding="2"> <tr> <th><span class="style2">Track</span></th> <th><span class="style2 style2">Race Started? </span></th> <th><span class="style2 style2">Race Start Time </span></th> </tr> <p> <? while ($i < $num) { $RaceStart = mysql_result($result,$i,"start"); $Track = mysql_result($result,$i,"track"); $i++; if ($RaceStart > $datetimeNOW) { ?> <tr> <th><? echo $Track; ?></th> <th><? echo "not started yet"; ?></th> <th><? echo $RaceStart; ?></th> </tr> <? } else { ?> <tr> <th><? echo $Track; ?></th> <th><? echo "Race Started"; ?></th> <th><? echo $RaceStart; ?></th> </tr> <? if ($Track == "Monthly Test" ) { // 1 exact month = 43830 $addrandminutes = rand(43200, 46080); // 30 to 32 days $newdate = strtotime("$datetimeNOW + $addrandminutes minutes"); $queryreset = "UPDATE races SET start = '$newdate' WHERE track = '$Track'"; mysql_query($queryreset); } else if ($Track == "Weekly test" ) { // 1 week = 10080 $addrandminutes = rand(9360, 10800); // 6.5 to 7.5 days $newdate = strtotime("$datetimeNOW + $addrandminutes minutes"); $queryreset = "UPDATE races SET start = '$newdate' WHERE track = '$Track'"; mysql_query($queryreset); } else { $addrandminutes = rand(10, 30); $newdate = strtotime("$datetimeNOW + $addrandminutes minutes"); // 10 to 20 minutes $queryreset = "UPDATE races SET start = '$newdate' WHERE track = '$Track'"; mysql_query($queryreset); } } } mysql_close(); ?> </table> </body> </html>
  15. I am creating a racing game and hit a snag. Been working on this all day (and most of the night) I need to set up the races so that players can enter them and race, then when the races is over it resets it with a random 10 to 30 minutes til the next race I have tried all sorts of things to get this to work. I have gotten closer and closer but here is where I stand now. lets say a race just ended, instead of resetting the time and adding 10 to 30 minutes, it sets everything to 0, it makes me think the variable is not valid and it tries to enter the date as a string or something. this is what I've come up with after trying it at least 50 different ways (the error is in the IF statement) Let me know what else I need to post, and thank you very much in advance for any help you can give me, both to fix this problem, and in helping me understand it <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Car Entered</title> <style type="text/css"> <!-- .style1 {color: #003300} .style2 {color: #990000} --> </style> </head> <body> <?php include 'connect.php'; mysql_connect("localhost",$user,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM races"; $result=mysql_query($query); $num=mysql_num_rows($result); $query2="SELECT * FROM account"; $result2=mysql_query($query2); $num2=mysql_num_rows($result2); $query3="SELECT * FROM tracks"; $result3=mysql_query($query3); $num3=mysql_num_rows($result3); $i=0; $datetimeNOW = date("Y-m-d H:i:s "); ?> <span class="style1">Current date/Time:</span> <? echo $datetimeNOW; ?> <table width="100%"border="1" cellspacing="2" cellpadding="2"> <tr> <th><span class="style2">Track</span></th> <th><span class="style2 style2">Race Started? </span></th> <th><span class="style2 style2">Race Start Time </span></th> </tr> <p> <? while ($i < $num) { $RaceStart = mysql_result($result,$i,"start"); $Track = mysql_result($result,$i,"track"); $i++; if ($RaceStart > $datetimeNOW) { ?> <tr> <th><? echo $Track; ?></th> <th><? echo "not started yet"; ?></th> <th><? echo $RaceStart; ?></th> </tr> <? } else { ?> <tr> <th><? echo $Track; ?></th> <th><? echo "Race Started"; ?></th> <th><? echo $RaceStart; ?></th> </tr> <? if ($Track == "Monthly Test" ) { // 1 exact month = 43830 $addrandminutes = rand(43200, 46080); // 30 to 32 days $newdate = strtotime('$datetimeNOW + $addrandminutes minutes'); $queryreset = "UPDATE races SET start = '$newdate' WHERE track = '$Track'"; mysql_query($queryreset); } else if ($Track == "Weekly test" ) { // 1 week = 10080 $addrandminutes = rand(9360, 10800); // 6.5 to 7.5 days $newdate = strtotime('$datetimeNOW + $addrandminutes minutes'); $queryreset = "UPDATE races SET start = '$newdate' WHERE track = '$Track'"; mysql_query($queryreset); } else { $addrandminutes = rand(10, 30); $newdate = strtotime('$datetimeNOW + $addrandminutes minutes'); // 10 to 20 minutes $queryreset = "UPDATE races SET start = '$newdate' WHERE track = '$Track'"; mysql_query($queryreset); } } } mysql_close(); ?> </table> </body> </html> This is the SQL setup, in case you need to look at that too. 1 start timestamp on update CURRENT_TIMESTAMP No CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP Change Change Drop Drop More Show more actions 2 track varchar(128) latin1_general_ci No None Change Change Drop Drop More Show more actions 3 acnt varchar(128) latin1_general_ci No None Change Change Drop Drop More Show more actions 4 car varchar(128) latin1_general_ci No None and the races entries as they ended up Full texts start track acnt car Edit Edit Edit Inline Edit Copy Copy Delete Delete 0000-00-00 00:00:00 test Edit Edit Edit Inline Edit Copy Copy Delete Delete 0000-00-00 00:00:00 test2 Edit Edit Edit Inline Edit Copy Copy Delete Delete 0000-00-00 00:00:00 test3 Edit Edit Edit Inline Edit Copy Copy Delete Delete 0000-00-00 00:00:00 Monthly Test Edit Edit Edit Inline Edit Copy Copy Delete Delete 0000-00-00 00:00:00 Weekly test
×
×
  • 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.