Jump to content

thechris

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thechris's Achievements

Member

Member (2/5)

0

Reputation

  1. I thought that was the way to go but I've never done something like that so how do I accomplish that task
  2. Ok I'm switching the game I'm developing from XML files over to using an online database, but what I did in XML was time consuming to do so I was looking for an easier way while I make the transition. Anyway here is what I'm doing: its a fighting game so I have a table for the character, another table for the attacks each character can only use certain attacks and some attacks can be used by all the characters, so I was wondering what the easiest way would be to make it so that when I'm loading the characters it lists only the attacks that they can use. I thought about making a field in the characters table and then putting the ID of the attacks that they can use, or the opposite and putting a field in the attacks with the ID's of the characters that can use the attack. That was kind of confusing I apologize, but I can't really explain it any better.
  3. I have everything almost done, but I can't figure out how to do one last thing. I'm trying to upload an image to a folder (got that done) and then save the file name into the mysql database (what I can't figure out) I know my code is a pretty big mess but here it is... <?php require_once('../Connections/connectdb.php'); ?> <?php if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg") && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "newitem")) { $insertSQL = sprintf("INSERT INTO items (item_name, item_category, item_price, item_description) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['name'], "text"), GetSQLValueString($_POST['category'], "text"), GetSQLValueString($_POST['price'], "text"), GetSQLValueString($_POST['description'], "text")); mysql_select_db($database_connectdb, $connectdb); $Result1 = mysql_query($insertSQL, $connectdb) or die(mysql_error()); } ?>
  4. ok i'm at a complete loss here is all the code for my page that i'm working on where it updates the form <?php require_once('../Connections/conn_users.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE battles SET player1_attack=%s, player1_defense=%s, player1_stamina=%s, player1_dexterity=%s, player1_special=%s, player1_health=%s, player2_attack=%s, player2_defense=%s, player2_stamina=%s, player2_dexterity=%s, player2_special=%s, player2_health=%s WHERE battle_id=%s", GetSQLValueString($_POST['player1_attack'], "int"), GetSQLValueString($_POST['player1_defense'], "int"), GetSQLValueString($_POST['player1_stamina'], "int"), GetSQLValueString($_POST['player1_dexterity'], "int"), GetSQLValueString($_POST['player1_special'], "int"), GetSQLValueString($_POST['player1_health'], "int"), GetSQLValueString($_POST['player2_attack'], "int"), GetSQLValueString($_POST['player2_defense'], "int"), GetSQLValueString($_POST['player2_stamina'], "int"), GetSQLValueString($_POST['player2_dexterity'], "int"), GetSQLValueString($_POST['player2_special'], "int"), GetSQLValueString($_POST['player2_health'], "int"), GetSQLValueString($_POST['battle_id'], "int")); mysql_select_db($database_conn_users, $conn_users); $Result1 = mysql_query($updateSQL, $conn_users) or die(mysql_error()); } mysql_select_db($database_conn_users, $conn_users); $query_battle = "SELECT * FROM battles ORDER BY battle_id DESC"; $battle = mysql_query($query_battle, $conn_users) or die(mysql_error()); $row_battle = mysql_fetch_assoc($battle); $totalRows_battle = mysql_num_rows($battle); $_POST['player_1'] = $row_battle['player_1']; $_POST['player_2'] = $row_battle['player_2']; $_POST['player1_char'] = $row_battle['player1_char']; $_POST['player2_char'] = $row_battle['player2_char']; $colname_player1 = "-1"; if (isset($_POST['player_1'])) { $colname_player1 = (get_magic_quotes_gpc()) ? $_POST['player_1'] : addslashes($_POST['player_1']); } mysql_select_db($database_conn_users, $conn_users); $query_player1 = sprintf("SELECT * FROM system_users WHERE username = '%s'", $colname_player1); $player1 = mysql_query($query_player1, $conn_users) or die(mysql_error()); $row_player1 = mysql_fetch_assoc($player1); $totalRows_player1 = mysql_num_rows($player1); $colname_player2 = "-1"; if (isset($_POST['player_2'])) { $colname_player2 = (get_magic_quotes_gpc()) ? $_POST['player_2'] : addslashes($_POST['player_2']); } mysql_select_db($database_conn_users, $conn_users); $query_player2 = sprintf("SELECT * FROM system_users WHERE username = '%s'", $colname_player2); $player2 = mysql_query($query_player2, $conn_users) or die(mysql_error()); $row_player2 = mysql_fetch_assoc($player2); $totalRows_player2 = mysql_num_rows($player2); $colname_player1_character = "-1"; if (isset($_POST['player1_char'])) { $colname_player1_character = (get_magic_quotes_gpc()) ? $_POST['player1_char'] : addslashes($_POST['player1_char']); } mysql_select_db($database_conn_users, $conn_users); $query_player1_character = sprintf("SELECT * FROM characters WHERE char_name = '%s'", $colname_player1_character); $player1_character = mysql_query($query_player1_character, $conn_users) or die(mysql_error()); $row_player1_character = mysql_fetch_assoc($player1_character); $totalRows_player1_character = mysql_num_rows($player1_character); $colname_player2_character = "-1"; if (isset($_POST['player2_char'])) { $colname_player2_character = (get_magic_quotes_gpc()) ? $_POST['player2_char'] : addslashes($_POST['player2_char']); } mysql_select_db($database_conn_users, $conn_users); $query_player2_character = sprintf("SELECT * FROM characters WHERE char_name = '%s'", $colname_player2_character); $player2_character = mysql_query($query_player2_character, $conn_users) or die(mysql_error()); $row_player2_character = mysql_fetch_assoc($player2_character); $totalRows_player2_character = mysql_num_rows($player2_character); $player1_attack = $row_player1['attack'] + $row_player1_character['attack']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Cosplay Combat</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="Robots" content="NOINDEX" /> <meta http-equiv="PRAGMA" content="NO-CACHE" /><!-- Web Site: www.ssi-developer.net Comments: Copyright 2003 www.ssi-developer.net Licence: Creative Commons - Non-commercial Share-Alike --> <link rel="stylesheet" type="text/css" href="../2c-hd-lc-static-layout.css" /> <link rel="stylesheet" type="text/css" href="../2c-hd-lc-static-presentation.css" /> </head> <body> <!-- Header --> <div id="hdr">Cosplay Combat </div> <!-- left column --> <div id="lh-col"> <ul> <li><a href="../index.php">Index</a></li> <li><a href="../gallery.php">Gallery</a></li> <li><a href="../rankings.php">Rankings</a></li> <li><a href="../rules.php">Rules</a></li> <li><a href="../request.php">Request Event</a></li> </ul> </div> <!-- end of left column --> <!-- right column --> <div id="rh-col"> <div id="info"><a href="../login.php">Log In</a> | <a>Log Out</a> | <a href="../registration.php">Register </a></div> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <table width="648" border="1"> <tr> <td width="300">Player 1 Name </td> <td width="332"><?php echo $row_battle['player_1']; ?></td> </tr> <tr> <td>Player 1 Character </td> <td><?php echo $row_battle['player1_char']; ?></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Player 2 Name </td> <td><?php echo $row_battle['player_2']; ?></td> </tr> <tr> <td>Player 2 Character </td> <td><?php echo $row_battle['player2_char']; ?></td> </tr> <tr> <td><a href="fight.php?battle_id=<?php echo $row_battle['battle_id']; ?>">Fight</a></td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> <p> <input type="hidden" name="battle_id" value="<?php $row_battle['battle_id']; ?>" /> <input type="hidden" name="player1_attack" value="<?php echo ($row_player1['attack'] + $row_player1_character['attack']); ?>"/> <input type="hidden" name="player1_defense" value="<?php echo ($row_player1['defense'] + $row_player1_character['defense']); ?>"/> <input type="hidden" name="player1_stamina" value="<?php echo($row_player1['stamina'] + $row_player1_character['stamina']); ?>"/> <input type="hidden" name="player1_dexterity" value="<?php echo($row_player1['dexterity'] + $row_player1_character['dexterity']); ?>"/> <input type="hidden" name="player1_special" value="<?php echo($row_player1['special'] + $row_player1_character['special']); ?>"/> <input type="hidden" name="player1_health" value="<?php echo ($row_player1['health']); ?>"/> <input type="hidden" name="player2_attack" value="<?php echo($row_player2['attack'] + $row_player2_character['attack']); ?>"/> <input type="hidden" name="player2_defense" value="<?php echo($row_player2['defense'] + $row_player2_character['defense']); ?>"/> <input type="hidden" name="player2_stamina" value="<?php echo($row_player2['stamina'] + $row_player2_character['stamina']); ?>"/> <input type="hidden" name="player2_dexterity" value="<?php echo($row_player2['dexterity'] + $row_player2_character['dexterity']); ?>"/> <input type="hidden" name="player2_special" value="<?php echo($row_player2['special'] + $row_player2_character['special']); ?>"/> <input type="hidden" name="player2_health" value="<?php echo($row_player2['health']); ?>" /> </p> <input type="hidden" name="MM_update" value="form1"> </form> <p></p> </div> <!-- end of right column --> </body> </html> <?php mysql_free_result($battle); mysql_free_result($player1); mysql_free_result($player2); mysql_free_result($player1_character); mysql_free_result($player2_character); ?>
  5. it works when it is not in the hidden field and displays the correct number but when it is in the hidden field the database just reads it as zero. I think that it is just not updating the table correctly because the forumla works when its out of the hidden field and i can put it in a variable and it'll print out the variable correctly but when I try to put the variable into the table it still reads as a zero. ???
  6. it returns a 0 when its posted to the new table in the database no they aren't strings they started as integers
  7. Title says it all. I have a hidden feild and would like to assign it a integer based of two numbers from different recordsets here is my code for what i tried <input type="hidden" name="player1_attack" value="<?php $row_player1['attack'] + $row_player1_character['attack']; ?>"/>
  8. I looked on the nulavatar forums already but couldn't find anything and I looked through the faq for it but couldn't find anything wrong there either. What i'm getting is the warning Warning: sort() expects parameter 1 to be array, null given in /Users/chrismorlang/Sites/admin/admin_nulavatar.php on line 674 here is the code [code] // // [START] Add image // if($action == "addimage") { $location = '<a href="'.append_sid($file.'?action=images').'" class="nav">'.$lang['nulavatar_loc_images'].'</a> -> <a href="'.append_sid($file.'?action=addimage').'" class="nav">'.$lang['nulavatar_loc_addimage'].'</a>'; // // [START] Create list with images! // $dir = @opendir($phpbb_root_path . $sprites_path); $firstimage = ''; while($file = @readdir($dir)) { if( !@is_dir(phpbb_realpath($phpbb_root_path . $sprites_path . '/' . $file)) ) { $img_size = @getimagesize($phpbb_root_path . $sprites_path . '/' . $file); if( ($img_size[0] == $img_width) && ($img_size[1] == $img_height) ) { $sprite_images[] = $file; } } } @closedir($dir); sort($sprite_images); //LINE GIVING ME THE PROBLEM $i_list = ""; for( $i = 0; $i < count($sprite_images); $i++ ) { if ($firstimage == '') { $firstimage = $sprite_images[$i]; } $i_list .= '<option value="' . $sprite_images[$i] . '">' . $sprite_images[$i] . '</option>'; } // // [END] Create list with images! // $sql = "SELECT * FROM ".$table_prefix."nulavatar_layers ORDER BY position DESC"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, "<b>Fatal Error!</b><br />".mysql_error()); } $l_list = ''; for( $i = 0; $i < mysql_num_rows($result); $i++ ) { $row = mysql_fetch_array($result); $l_list .= '<option value = "'.$row['id'].'">'.str_replace("_"," ",$row['name']).'</option>'; } $noshow = '<option value = "">'.$lang['nulavatar_dont_use_nolayer'].'</option>'; $useaction = ' <tr><td class="row1" align="center"><span class="gen"> <br /><b>'.$lang['nulavatar_addimage'].'</b><br /><br /> <form action="" method="post"> <table width="60%" cellpadding="10" cellspacing="0"> <tr> <td width="40%" class="row2"><span class="gen"><b>'.$lang['nulavatar_name'].'</b></span></td> <td width="60%" class="row2"><span class="gen"><input type="text" name="name" value=""></span></td> </tr> <tr> <td width="40%" class="row2"><span class="gen"><b>'.$lang['nulavatar_image'].'</b></span></td> <td width="60%" class="row2"><span class="gen"><img src="'.$phpbb_root_path.$sprites_path.'/'.$firstimage.'" name="preview"><br /><select name="image" onChange="document.images[\'preview\'].src = \''.$phpbb_root_path.$sprites_path.'/\'+ this.value;">'.$i_list.'</select></span></td> </tr> <tr> <td width="40%" class="row2"><span class="gen"><b>'.$lang['nulavatar_layer'].'</b></span></td> <td width="60%" class="row2"><span class="gen"><select name="layer">'.$l_list.'</select></span></td> </tr> <tr> <td width="40%" class="row2"><span class="gen"><b>'.$lang['nulavatar_dontshowlayer'].'</b></span><span class="gensmall"><br />'.$lang['nulavatar_dontshowlayer_explain'].'</span></td> <td width="60%" class="row2"><span class="gen"><select name="dontshowlayer">'.$noshow.$l_list.'</select></span></td> </tr> <tr> <td width="40%" class="row2"><span class="gen"><b>'.$lang['nulavatar_itemneeded'].'</b></span><span class="gensmall"><br />'.$lang['nulavatar_itemneeded_explain'].'</span></td> <td width="60%" class="row2"><span class="gen"><input type="text" name="itemneeded" value=""></span></td> </tr> </table> <br /> <input type="hidden" name="action" value="doaddimage"><input type="submit" class="mainoption" value="'.$lang['nulavatar_addimage'].'"><br /><br /></span></th> </form> </span></td></tr> '; } // // [END] Add image // [/code]
  9. There is only one php.ini file in my folder and I cannot find another one anywhere I moved all my extensions into the php5 folder where it says its looking for them but php still won't load the extensions
  10. I have my php.ini file all configured to load the extensions [code]extension_dir = "C:\php5\ext\"[/code] I tried to install phpmyadmin and it told me I couldn't load the extensions so I looked at the phpinfo(); and it tells me that my extension directory is C:\php5. So I went and checked my php.ini file again but it still says that my extension directory is set to C:\php5\ext So I'm at a total loss for what I need to do
  11. [quote author=SemiApocalyptic link=topic=115439.msg470085#msg470085 date=1163868439] Heres a method of doing it, although I have only made it plot the health, stamina and dexterity points, it should be quite simple to work out how to make it plot the other four points. The only issue with this method is that the pink line is only 1px thick, I'm not sure of an easy method to make it thicker other than to create the polygon several times with a slight offset... Hope this helps... [code]<?php function buildimage($h,$s,$d) {     $health = array("128,122","119,99","111,77","104,58","97,38","90,22");     $stamina = array("128,122","140,102","152,81","163,62","175,48","182,33");     $dexterity = array("128,122","149,120","167,118","190,116","209,113","230,103");         $coords = explode(",",$health[$h].",".$stamina[$s].",".$dexterity[$d]);     $im = imagecreatefromjpeg("base.jpg");     $col_poly = imagecolorallocate($im,201,0,201);     imagepolygon($im,$coords,count($coords)/2,$col_poly);     header("Content-type: image/png");     imagepng($im); } buildimage(0,1,2); ?>[/code] [b]EDIT:[/b] Turns out you can set the thickness of the line with the imagesetthickness() function! [/quote] It tells me when I test it in a browser The image “http://localhost/cosplaycombat/test.php” cannot be displayed, because it contains errors. I changed the code to load the blank image because I don't have it named as you did What version of PHP do I need to have to correctly use this because I have php 5.2.0
  12. Ok I'm not sure if this is possible or not but I thought I would ask. When looking at a characters stats I want to have thier data displayed like this [IMG]http://img.photobucket.com/albums/v63/vokus/0000534.jpg[/img] but I don't want to make images for all the combos and was wondering if I could do it based off of thier stats from the database and how would I do it?
  13. On my page I have it so that it will list out all the anime but you can narrow your search by clicking on the alphabet on the top but when you click on one of the letters the alphabetical list disappears. [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>iAnime Downloads</title> <link href="Styles/basic.css" rel="stylesheet" type="text/css"> <link href="Styles/nav.css" rel="stylesheet" type="text/css"> <link href="Styles/menu.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style2 {color: #FFFFFF} --> </style> <?php require_once('Connections/connectDB.php'); ?> </head> <body> <div id="wrapper"> <div id="titlebar"><img src="Images/ban.png"></div> <div id="nav"> <ul> <li><a href="home.php">Home</a></li>     <li><a href="downloads.php">Downloads</a></li>     <li><a href="forum.php">Forums</a></li>     <li><a href="support.php">Support</a></li>     <li><a href="ianime.php">iAnime</a></li> </ul> </div> <div id="top"><img src="Images/top.png"></div> <div id="main content"> <div id="alphabet"> <?php global $Key; $Key = $_REQUEST['Key']; if (!$Key) {   $ASCII= 65; # uppercase (+32 for lowercase)   $i = 1;   while ($i < 27) {     $Char = chr($ASCII);     echo("<a href='?Key=$Char'>$Char</a>");     if($i < 26) {     echo(" - ");     }     $i++;     $ASCII++;   } } else {   $SQL = sprintf("SELECT anime_name, type  FROM Videos WHERE anime_name LIKE '$Key' ORDER BY anime_name ASC"); } ?> </div> <div id="list"><center> <?php mysql_select_db($database_connectDB, $connectDB); $query_Recordset1 = "SELECT anime_name, type FROM Videos WHERE anime_name LIKE '$Key%' ORDER BY anime_name ASC"; $Recordset1 = mysql_query($query_Recordset1, $connectDB) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <br> <table width="375" border="0">   <tr bgcolor="#FF00FF">     <td width="81"><span class="style2">Type</span></td>     <td width="284"><span class="style2">Name</span></td>   </tr>   <?php do { ?>   <tr>       <td><?php echo $row_Recordset1['type']; ?></td>       <td><?php echo $row_Recordset1['anime_name']; ?></td>   </tr>   <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> </center> </div> </div> <div id="bottom"> <div id="word"> &copy; <?php echo date('Y'); ?> </div> </div> </div> </body> </html> <?php mysql_free_result($Recordset1); ?> [/code]
  14. i installed php and mysql and I can use mysql through the command line but when i installed phpmyadmin and created my config.inc.php file I get this error in my phpMyAdmin page "The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results." in my php.ini file I do have the mbstring.dll enabled
×
×
  • 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.