Jump to content

cliftonbazaar

Members
  • Content Count

    165
  • Joined

  • Last visited

Community Reputation

0 Neutral

About cliftonbazaar

  • Rank
    Advanced Member

Contact Methods

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

Profile Information

  • Gender
    Male
  • Location
    Adelaide Hills
  1. cliftonbazaar

    TRIM quotation marks

    Then wouldn't stripping the quotation marks also stop the injection attack? At the moment it only happens when there are quotation marks around their middle name, this is pulled information from a third party site so I can't stop it on their end.
  2. cliftonbazaar

    TRIM quotation marks

    I have the following code $sql_statement = "SELECT * FROM toon WHERE ally_code = '".$user['ally_code']."' and name = '".$toons_array[$i][1]."' LIMIT 1"; Which works except if the persons 'name' has quotation marks in it, for example the name of Adam "Danger" Smith doesn't match with Adam Danger Smith. My best attempt was $sql_statement = "SELECT * FROM toon WHERE ally_code = '".$user['ally_code']."' and trim( both '"' from name) = '".$toons_array[$i][1]."' LIMIT 1"; Any suggestions please?
  3. cliftonbazaar

    decbin() - Is there an upper limit?

    Thanks for the explanation and the better way of doing it
  4. cliftonbazaar

    decbin() - Is there an upper limit?

    From what I have read decbin has an upper limit of 2 to the power of 52, so what is going wrong with this code? function teams($number){ $number = decbin($number); //Change the number to Binary if($number % 10) {echo " <font color=green>ARENA</font> ";} //1 if($number / 10 % 10) {echo " <font color=maroon>FLEET</font> ";} //2 if($number / 100 % 10) {echo " <font color=yellow>FLEET RESERVE</font>";} //4 if($number / 1000 % 10) {echo " <font color=gold>FLEET COMMANDER</font>";} //8 if($number / 10000 % 10) {echo " <font color=fuchsia>RANCOR</font> ";} //16 if($number / 100000 % 10) {echo " <font color=darkblue>AAT</font> ";} //32 if($number / 1000000 % 10) {echo " <font color=tomato>SITH</font> ";} //64 if($number / 10000000 % 10) {echo " <font color=blue>LSTB(1)</font> ";} //128 if($number / 100000000 % 10) {echo " <font color=blue>LSTB(2)</font> ";} //256 if($number / 1000000000 % 10) {echo " <font color=blue>LSTB(3)</font> ";} //512 if($number / 10000000000 % 10) {echo " <font color=blue>LSTB(4)</font> ";} //1024 if($number / 100000000000 % 10) {echo " <font color=blue>LSTB(5)</font> ";} //2048 if($number / 1000000000000 % 10) {echo " <font color=blue>LSTB(6)</font> ";} //4096 } Now if the number is less than, or equal to, 2048 then everything is fine, it's when the number is over 2048 a lot more gets printed. On the attached screenshot I have the numbers on the far right, the decimal number is 3584, which outputs the correct binary code which means the function should only print the 3 lines before the last, but in the screen shot it shows that it also prints the first 2 lines of the code. What am I doing wrong and how can I fix it? Or what is another solution if I can't get this fixed? James
  5. cliftonbazaar

    Finding a variable in an array

    Thanks Benanamen, that's excactly what I'm after. This code is working out ratings based on what is in the database, so all the data has been stored, I now have to work out the results. This is part of a much bigger project so I need to be able to integrate the data with other parts which this array has done.
  6. cliftonbazaar

    Finding a variable in an array

    I have an array of $my_heroes = ("Batman", "Superman", "Spiderman", "Hulk"); Note that this array will expand over time as more 'Heroes' are added. Each Hero is to have a value added, depending on several things, and then sorted at the end. My thinking is to have a 2 Dimensional array. So my question is how do I change my array into a 2D array and then add a value, so for example after round one of fighting I wish to give Batman 10 points, Superman 15 points and Hulk 20 points. I have tried $$my_heroes[0] += 10; but this turned out to be a disaster. So the end result I want is $my_heroes_results[0][0]="Batman"; $my_heroes_results[0][1]=10; $my_heroes_results[1][0]="Superman"; $my_heroes_results[1][1]=15; $my_heroes_results[2][0]="Spiderman"; $my_heroes_results[2][1]=0; $my_heroes_results[3][0]="Hulk"; $my_heroes_results[3][1]=20; Then I can sort them into order.
  7. Currently my code is $sql_statement="UPDATE players SET cls = '".$_GET['cls']."', rjt = '".$_GET['rjt']."', thrawn = '".$_GET['thrawn']."', rolo = '".$_GET['rolo']."', ipd = '".$_GET['ipd']."', arena1 = '".$_GET['arena1']."', arena2 = '".$_GET['arena2']."', arena3 = '".$_GET['arena3']."', arena4 = '".$_GET['arena4']."', arena5 = '".$_GET['arena5']."', fleet1 = '".$_GET['fleet1']."', fleet2 = '".$_GET['fleet2']."', fleet3 = '".$_GET['fleet3']."', fleet4 = '".$_GET['fleet4']."', fleet5 = '".$_GET['fleet5']."' WHERE ally_code = '".$_SESSION['ally_code']."'"; Each GET is the same as the column in my database; is there a loop to make this smaller in code? The reason I ask this is because it's going to get bigger and bigger. While I realise that this isn't the best way to update the database it works for my needs. James
  8. cliftonbazaar

    Getting a single value from a result

    Hi, If my table is Batman Human 45 Superman Alien 33 How do I display Superman's race and age? Currently I have $sql_statement = "SELECT * FROM heroes"; $toons=mysqli_query($mysql_DB, $sql_statement); while($toons = mysqli_fetch_array($results, MYSQLI_ASSOC)) { echo name; } But this shows all the results where I only want one. Yes I know I could do a "WHERE name = Superman" in the statement but I want the whole table loaded in as I wish to use the other name (Batman) in another part of the program. Please note that this is only a sample data table, the real table is a lot bigger (42k rows so I can't simply do a new sql call each time).
  9. cliftonbazaar

    Putting a persons data into an array

    Sorry to have to bump but I cannot work out how to display the answers; I can do the JOIN but not display the answers how I need
  10. cliftonbazaar

    Putting a persons data into an array

    JOIN is easy if they were the only toons in the database but they are not, in fact they can be out of order for some players
  11. cliftonbazaar

    Putting a persons data into an array

    So I have two tables (one small, one large), the first table is called 'profile' and has each players name, the second table is called 'toon' and has each players characters. What I am trying to do is output the players (which is easy to do with mysqli_fetch_array) but I also wish to output some of the players toons with their power level. table 'profile' 1 James 2 Darren table 'toons' 1 Batman 456 1 Superman 789 2 Batman 1245 2 Superman 564 The output I want is NAME BATMAN SUPERMAN James 456 789 Darren 1245 564 Obviously this is a simplication of what I am doing Currently I was looping through all the profiles and then inside each loop calling each row of the toon I wanted but I soon realised that there must be a better way than making 1,500 calls to the database! James
×

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.