Jump to content

Perad

Members
  • Posts

    287
  • Joined

  • Last visited

    Never

Everything posted by Perad

  1. What I want to do is simply add an amount to the ucp_game_credits column. I do not want to call out what it is first. i.e. ucp_game_credits += $newammount How can I do this in SQL? $sql = "UPDATE ucp_users SET ucp_game_credits='???' WHERE ucp_id='". $_SESSION['uid']."'";
  2. This is a multi-dimensional array so I feel that I have labeled it correctly. technology name => technology values => value attributes Anyway print_r outputs the following. I have added line breaks after each value of the $defense array.
  3. OK, this is strange. The count statement prints '3'. This is correct as there are 3 items in this array. However the 'print $technology' statement only brings back one result. Can someone tell me why this is? print count($defense); foreach($defense as $technology=>$values) { print $technology; // Grab Unit Name $tech_d_name[] = $technology; $tech_d_form_name[] = str_replace(" ", "!", $technology); foreach ($defense as $value=>$attributes) { // Grab Unit costs if ($value == "price") { $tech_d_credits[] = $attributes; } if ($value == "description") { $tech_d_description[] = $attributes; } foreach ($attributes as $key=>$val) { switch ($key) { case "levels": $tech_d_levels[] = $val; break; case "scale": $tech_d_scale[] = $val; break; } } if ($value == "resources") { foreach ($attributes as $key => $val) { switch ($key) { case "ore": $tech_d_cost_ore[] = $val; break; case "man": $tech_d_cost_man[] = $val; break; case "titanium": $tech_d_cost_titanium[] = $val; break; case "plasma": $tech_d_cost_plasma[] = $val; break; case "lead": $tech_d_cost_lead[] = $val; break; } } } }
  4. I have an out of the box XAMPP server on the Mac which is leading to my local server giving up on textilephp processing. It has no problems with any other files. A test file works fine on my online web server. Can anyone think of any php settings that I should check to get this running? I have php 5 on my local host.
  5. It echo's fine. It's weird, its like the array is creating a look to infinity..
  6. Could it be that the array contains value contains numbers?
  7. That doesn't work.. On closer inspection... $upcf_data[] = array( "ucpf_compulsory" => $row['ucpf_compulsory'] ); Doesn't work. This does $upcf_data[] = array( "ucpf_name" => $row['ucpf_name'] ); However the code below works fine. print $row['ucpf_compulsory'];
  8. Error line is 145 and line 145 is the line starting $upcf_data shown below. $upcf_data[] = array( "ucpf_name" => $row['ucpf_name'], "ucpf_compulsory" => $row['ucpf_compulsory'] );
  9. The table has only got 7 rows.. If I replace the array with print 1; Seven 1's are printed. However with the array it just freezes.
  10. I have 2 arrays... one works and one doesn't. The first one brings about this error. Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /Applications/xampp/xamppfiles/htdocs/minisite/scripts/user_cp/register.php on line 145 $sql = "SELECT * FROM ucp_fields"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $upcf_data[] = array("ucpf_name" => $row['ucpf_name'], "ucpf_compulsory" => $row['ucpf_compulsory'] ); } This one has no error. From what I can tell they are both identical... $sql = "SELECT * FROM ucp_fields"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { if ($row['ucpf_compulsory'] == 1) { $ucp_forms_compulsory[] = array( "ucpf_name" => $row['ucpf_name'], "ucpf_maxlength" => $row['ucpf_maxlength'], "ucpf_type" => $row['ucpf_type'], "ucpf_register_values" => $row['ucpf_register_values'] ); } } Help finding what is causing this would be very very welcome
  11. Wes, in regards to your answer, what are the square brackets for?
  12. I have an array which has $key and $values set. I want to randomly select one of these values. How would I do this?
  13. 1) You could use something like Smarty. Smarty allows you to create HTML templates then assign php variables to the template. This allows you to create clean and structured and code. If you do not want to do that then create a new file. page.php page.php should be a html page. Instead of having the title and content you would have <?php $title ?> and <?php $content ?> After you have called the data from the database and assigned them to $title and $content variables you can include the page.php which will then assign the variables to the page.php file. 2) Here is one way. After executing this code you can just print out the array where you need it. // Get title from database while ($row = mysql_fetch_assoc($result) { $navigationarray[] = '<a href="index.php?page=$row['title']">$row['title']</a>'; }
  14. Its not out of your league, it just needs some more thought. Lets say the user wants to add a new page. The page contains a title and some content. Database Table called pages The user enters page title and content which is stored into the pages table. $title = escape_string($_GET['page']); $sql = "SELECT * FROM pages WHERE title='$title'"; $result = mysql_query($sql); if (mysql_fetch_rows($result) != 0) { $title = $row['title']; $content = $row['content']; } The above code can be improved but you should get the idea.
  15. site.com/index.php?page=contact if ($_GET['page'] == contact) { // Add PHP for contact page here. }
  16. OK, I found something similar and it says that I cannot use an absolute path for this. What PHP function could I use to find the relative position of the wordpress folder?
  17. I have changed getcwd(); to get_option('port_url') in an attempt to make this a little more dynamic. However I am now getting errors. Could someone help to tell me what is going wrong. Error: get_option('port_url') = http://localhost/wordpress/portfolio/ PHP $target_path = get_option('port_url'); if(!file_exists($target_path)) { mkdir($target_path); } /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename($_FILES['port_spic']['name']); if(move_uploaded_file($_FILES['port_spic']['tmp_name'], $target_path)) { $smallimage = $_FILES['port_spic']['name']; } else{ print "There was an error uploading the small image, please try again!"; } $target_path = $target_path . basename($_FILES['port_lpic']['name']); if(move_uploaded_file($_FILES['port_lpic']['tmp_name'], $target_path)) { $largeimage = $_FILES['port_lpic']['name']; } else{ print "There was an error uploading the large image, please try again!"; }
  18. Hey, can someone help me turn the following code below into a multidimensional array like the following. $this->field - Name - Type - Length I just can't get my head around it. $sql = "DESCRIBE $table"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $this->field[] = $row['Field']; // Separate Length From Type $type = $row['Type']; $values = array("(", ")"); $split = str_replace($values, " ", $type); $explode = explode(" ", $split); // End $this->type[] = $explode[0]; $this->length[] = $explode[1]; }
  19. Basically I want the below to work but it isn't. How do I get this going? $this->datadisplay[] = $val => $tval;
  20. $user = $_GET['user']; is $_GET['user'] defined in the URL? i.e.. page.php?user=Fred
  21. Take this example. $sql = "DESCRIBE users"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); foreach ($row as $key => $val) { print $key . " - ". $val. "<br />"; } This only prints out the first field in the table. How do I use php to print them all?
  22. I am looking at it... I don't see it. Trying to generate the right errors at the right time. However this error becomes an error even when it shouldn't be. This is to restrict usernames. $resnames = array("guest", "admin", "administrator"); foreach ($resnames as $key => $val) { if ( $useralias == $val) { print "$useralias = $val"; $this->rerror = TRUE; return $this->rerror; } } html - using smarty templating engine {elseif $rerror} <div class="error"> <p>You have selected a restricted username, please try again.</p> </div> {elseif $emptyerror} what I get when I load the page... 1 = guest You have selected a restricted username, please try again. 1 doesn't equal guest so it shouldn't be coming up. Any ideas?
  23. yes e.g. 2007-10-08 12:10:47
×
×
  • 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.