Jump to content

xangelo

Members
  • Posts

    102
  • Joined

  • Last visited

    Never

Everything posted by xangelo

  1. Is round() not working for you? It should have fixed your 7.3333 issue.
  2. Actually the problem is here: $info=mysql_fetch_assoc($queryresult); Replace everything from $query to //otherwise with the following. $query='select seller,id,title from listings where seller = "'.$data['username'].'"'; $queryresult=mysql_query($query,$conn); while($info = mysql_fetch_assoc($queryresult)){ echo "{$info['title']}"; }
  3. Action is the url of the page that will process the form. So if your page is called form.php action would be form.php
  4. You would access the value via $_POST. So: $_POST['choice'] would equal either FP,BP,PP,CP or NULL depending on what was chosen. To format it more in line with your code switch($_POST['choice']){ case 'FP': $printchoice = 'Front Print'; break; case 'BP': $printchoice = 'Back Print'; break; case 'PP': $printchoice = 'Pocket Print'; break; case 'CP': $printchoice = 'Custom Print'; break; default: $printchoice = 'Front Print'; break; } I added a default value, incase the user doesn't select anything. Another way (if you don't have to do any further processing) would be like this: $allowed = array('FP'=>'Front Print','BP' => 'Back Print', 'PP' => 'Pocket Print', 'CP' => 'Custom Print'); if(array_key_exists($_POST['choice'],$allowed)) { $printchoice = $allowed[$_POST['choice']]; }
  5. ../ That will take you one level above. Just keep adding them for each directory higher you need to go. Your example would be: $fp = fopen("../emails.txt", "w");
  6. Set the action. Some browsers will fill it in as the current page, others will not know what to do.
  7. Based on the $check array, 0 is fail, 1 is success. So I generate either 0 or 1 randomly, and if it's 1 then we proceed with the script.
  8. I've re-written your code to make things a little easier to follow. If this doesn't work, make sure $_SESSION['username'] is being set. <?php if($_POST['option'] == 1) { $amount = rand(0,400); $check = array( 'You have failed to jack her', 'You have successfully jacked her and receieved £'.$amount.' from the jacking' ); if(rand(0,1) == 1) { $connect = mysql_connect("localhost","root","") or die("<center>Did not connect to database.</center>"); mysql_select_db("thegame") or die("<center>Couldn't find the database.</center>"); $sql = 'update users set money = money+'.$amount.' where username = "'.$_SESSION['username'].'"'; if(mysql_query($sql)) { echo $check[1]; } } } ?>
  9. From what you described, I think you're looking for this: http://ca.php.net/manual/en/function.sleep.php but depending on what you are trying to do there may be a better answer.
  10. That is happening because you are using $random_number before it is actually initialized. If you move your $random_number = rand(0,400); line above the $success line you should be good. Also, is the database being updated with the data even if it is not being displayed?
  11. Your check isn't actually doing anything. if($successorfail == $success) doesn't make sense. it should be $successorfail[0] == $success The first way will ALWAYS evaluate to true because you are assigning $success to $successorfail as opposed to performing a boolean check. Is the database being updated?
  12. get rid of the mysql_query($query) line. Also, are you receiving any errors?
  13. You're looking for this: http://ca.php.net/manual/en/function.round.php
  14. I'm developing a module for the Drupal CMS and part of it requires utilizing CKEditor and inserting a button. I'm not trying to do anything fancy here, just get the button to appear but for the life of me it just refuses to. I've tried multiple methods following various online tutorials and I can't seem to get it to work. I'm not really looking for code, just a method for compiling my custom plugin (located in ckeditor/plugins/helloworld) to work with ckeditor. Thanks in advance, Angelo
  15. Not a problem, glad to be of help. I thought I'd include a more detailed explanation incase you were interested. ----- mysql_fetch_array() returns an array resource. So when you are selecting 'propertyName' from the database, mysql is returning something more like array('propertyName'=>'value'); . We are then assigning that array to a variable called property. So $property = array('propertyName'=>'value'); . To access propertyName we use $property['propertyName'] By incoporating the assignment ($property = mysql_fetch_array()) into the while statement, we make PHP loop over each result that was returned and assign it one by one to $property.
  16. In the loop do this: echo '<pre>'.print_r($property,true).'</pre>'; propertName is nothing but a key in the array, so you will get nothing outputted. The actual variable is called $property
  17. What you're looking for is a caching solution. Depending on the type of project anything from flat files to memcache would work.
  18. I thought as much. I corrected my post to include a fix for the new single/double quote issue which is what is throwing the error.
  19. What you're essentially looking for is to couple thorpe's idea with onlyican. You'll need to run an asynchronous javascript request which would run the query and output the results as either xml or json. Your javascript can then deal with it as you want. I'd advise you to look at a javascript library such as jQuery, Dojo or MooTools. Their implementations of AJAX are cross browser. They also have tutorials on how to use them in their documentation.
  20. <?php $name_print= array(); for($i = 0 ; $i < $query_report_rows ; ++$i) { $row= mysql_fetch_row($query_names); if($row[6] == 0) { $sName = $row[1]; } elseif($row[6] == 1) { $sName = $row[2]; } $name = "$row[0], $sName"; $print = nl2br($row[7]); $name_print[] = array('name'=>$name,'print'=>$print); }
  21. Your method is only using the first returned result, by incorporating the $property=mysql_fetch_array() into the while statement, you can loop through each returned statement. *Edit* I realized this may not work because of the quotes, so I changed it. <?php function getProperties(){ $sql = "SELECT propertyName FROM properties;"; $result = mysql_query($sql); //$count = mysql_num_rows($result); while($property = mysql_fetch_array($result){ echo '<td width="157" height="24" valign="middle"><div align="left"><input type="checkbox" name="'.$property['propertyName'].'" "id="'.$property['propertyName'].'" />'.$property['propertyName'].'</div></td>'; }?>
  22. The single/double quote thing is irrelevant for what you require. Either will work just as well as the other. If you're just looking for the contents of a file, file_get_contents like n4iko mentioned will work fine. If you absolutely NEED the full path, there is an allow_url_include in your php.ini file that you can turn ON.
  23. The code wouldn't really help you too much without a long winded explanation, but this website explains it all very well and also provides you code examples. http://www.desiquintans.com/cleanurls You would still need to store the profile information in a database of some kind to make best use of it.
  24. The method I'm presenting can be fairly complex if you want it to be, but for the explanation I'm going to keep it simple and easily understood. The easiest way would be to create a pixel-based grid, say 10x10 to start with. Each pixel would correspond to a tile. This way you keep your map size down and aren't running to a database to pull this information. Plus, creating new maps will be a breeze. I'd say let certain colors represent certain areas. So for example lets take the following: light green: grass blue: water black: rock grey: anywhere you can walk Your map could be a randomization of any of these colors and would take up a small amount of space. You could store the map information (name,id) in a database and reference it based on your user location data. Load up the map and utilizing php GD we could first figure out the exact pixel that the user is on based on their location data (x,y). Then a 3x3 square around them would be as follows: +-----------+-----------+-----------+ | x-1,y+1 | x,y+1 | x+1,y+1 | +-----------+-----------+-----------+ | x-1,y | x,y | x+1,y | +-----------+-----------+-----------+ | x-1,y-1 | x,y-1 | x+1,y-1 | +-----------+-----------+-----------+ You simply grab the color at those pixels and translate them into the appropriate images (ie, if x-1,y-1 is black include an image of a rock).
  25. There is a better way to go about it than what you are describing, but I'll answer your question first and then post what I think. First you'll need a database to store the user information. The username, a unique user_id, password etc. Whenever a user registers, you'll have to do a lookup to see if the username already exists. If it doesn't, then we can insert the new information into the database and then do the following. mkdir() will create the directory fopen() + fwrite() to create the index.html http://www.tizag.com/phpT/filewrite.php http://ca3.php.net/manual/en/function.fopen.php http://ca3.php.net/manual/en/function.mkdir.php http://ca2.php.net/manual/en/function.fwrite.php ------ How I would do it is slightly different. Unless I'm letting users store files on my website (and even then... I'd rather centralize that) I would rather give them virtual directories. Meaning, if they go to www.mydomain.com/username it will show their user profile. This is more commonly done through the use of .htaccess files that parse something like www.mydomain.com?q=username to www.mydomain.com/username. If you are interested in this method, please say something, otherwise the method posted above will work.
×
×
  • 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.