Jump to content

monkeypaw201

Members
  • Posts

    376
  • Joined

  • Last visited

Everything posted by monkeypaw201

  1. I'm not particularly familiar with the class you are using, but you may be better off exploding (and make a new line) every x characters..
  2. Take a look at a file upload tutorial: http://www.w3schools.com/PHP/php_file_upload.asp From there, you can just save the data to a database and call it when necessary.
  3. Sure, thats pretty easy. First, you'll need to retrieve the current number from the URL with something like this; <?php //retrieve current number $currentnumber = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); // then you redirect header("Location: http://www.mydomain.com/".($currentnumber+1)); ?> The parse_url function is explained here:http://php.net/manual/en/function.parse-url.php EDIT: beat me to it
  4. I don't know what your database looks like, but here is a sample snippet I used on a website once. I'm sure with a bit of tweaking, you can get it to work the way you want. <?php $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $invoice_id = $_POST['custom']; if (!$fp) { echo "error connecting to paypal"; } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $this->db->query("INSERT INTO `transactions` (`iid`,`gateway`,`gateway_id`,`amount`,`status`,`timestamp`) VALUES ('".$invoice_id."','paypal','".$txn_id."','$payment_amount','verified','".time()."')"); $this->db->query("UPDATE `invoices` SET `status` = 'paid' WHERE `iid` = '".$invoice_id."'"); } else if (strcmp ($res, "INVALID") == 0) { $this->db->query("INSERT INTO `transactions` (`iid`,`gateway`,`gateway_id`,`amount`,`status`,`timestamp`) VALUES ('".$invoice_id."','paypal','".$txn_id."','$payment_amount','invalid','".time()."')"); } } fclose ($fp); } ?>
  5. You can use the mysql_real_escape_string() function. http://php.net/manual/en/function.mysql-real-escape-string.php Foreach value, run it through the function; $newvariable = mysql_real_escape_string($oldvariable);
  6. I encountered a similar dilemma a while back and fixed it with a bandaid; Just do a str_replace() right before inserting. I'm sure there is a better way, but it works. // Check if edit source is on or off if ($sourceStatus == 1) { echo ('<h3>Edit Page Source: '.$title.'</h3>'); // Open file $file = fopen("../".$page.".php","r+") or exit("Unable to open file!"); echo '<p><form action="edit.php?page='.$page.'&source=edit" method="post">'; echo '<input type="hidden" name="updateSource" value="true" />'; echo '<p><textarea rows="20" name="sourceCode" cols="75" id="sourceCode">'; //Output a line of the file until the end is reached while(!feof($file)) { echo fgets($file); } // close file fclose ($file); echo '</textarea></p>'; echo '<button type="submit">Update Page</button>'; echo "<button type="."button"." onclick="."location.href='delete.php?delete=".$page."'".">Delete Page</button>"; echo '</form>'; // if updated re-write file if ($updateSource == true) { // Capture data $sourceCode = str_replace("\\","",$_POST['sourceCode']); // write to the file $file = fopen("../".$page.".php","w+") or exit("Unable to open file!"); fwrite ($file, $sourceCode); fclose ($file); echo "<meta http-equiv='refresh' content='0;URL=edit.php?page=$page'>"; }
  7. I have the string below which has variable text in between the div tags. I need to just remove the entire div (and the linebreak) IF its on the page. I've been told to try preg_replace() but after about 30 minutes at looking at tutorials I still can't make heads or tails of whats going on.. <br><div style='margin-right:10px;margin-top:4px;color:#a0a0a0;font-size:9px;text-align:right;font-style:italic'>CHANGING TEXT HERE</div> I was hoping someone could explain how I'd go about making the preg_replace() for this one and may help me catch on.. Thanks in advance
  8. I have a snippet of code from my page here: $filtered2 = str_replace(" nm</td><td class=results width=50 style='align:center'><a href='?site=pl&show=700579c68127f8f25825b1efb8c2f56d' class='link'>details</a></td></tr>","",$sort[1]); But the &show=<value> is always different, yet i need to replace that string regardless... How can this be done? (I prefer code and an explanation if possible)
  9. How about an HTML-to-PDF class? (free) http://www.phpclasses.org/browse/package/2905.html
  10. Generate every possible combination of the $chars with a defined length. ie AAAA, AAAa, AAAB, AAAb, AAAC, AAAc, etc.. ie AAA, AAa, AAB, AAb, AAC, AAc, etc..
  11. Well, my first question is where does the poem_id and user_id come from?
  12. Alright, so i have the code below, and i've run it up to (and including) 3 Characters, but after that it wants over 256MB or Memory (hosting provider won't allocate more than that). Is there any way to break it up into smaller chunks? [code<?php $chars = array("A","a","B","b","C","c","D","d","E","e","F","f","G","g","H","h","I","i","J","j","K","k","L","l","M","m","N","n","O","o","P","p","Q","q","R","r","S","s","T","t","U","u","V","v","W","w","X","x","Y","y","Z","z"," ","`","~","1","!","2","@","3","#","4","$","5","%","6","^","7","&","8","*","9","(","0",")","-","_","=","+","\"","|","}","{","]","[",";",":","?","/",".",">","<"); function comb($a, $len){ if ($len > count($a))return 'error'; $out = array(); if ($len==1) { foreach ($a as $v) $out[] = array($v); return $out; } $len--; while (count($a) > $len) { $b = array_shift($a); $c = comb($a, $len); foreach ($c as $v){ array_unshift($v, $b); $out[] = $v; } } return $out; } $test = $chars; $a = comb($test,$_GET['number']); $count = 0; foreach($a as $arr) { //print_r($arr); $string = ""; $count++; foreach($arr as $outrr) { $string .= $outrr; //echo "<br>"; //echo "-"; } //echo $string; //echo "-"; //echo "<br>"; //echo "<hr>"; mysql_query("INSERT INTO `sha1` (`string`) VALUES ('$string')"); } echo $count; ?>
  13. Well if its a monospace font.. the font size would define the width and height right? In which case you could just count the number of letter and multiply by the font size..
  14. Is there any way to calculate the pixel width of a word if given the font and the size?
  15. well, you could always go back and re-query for the latest entry that matches the name & data you just entered $result= mysql_query("SELECT * FROM `table` WHERE `Name` = '$NameData' AND `Data` = '$DataData' ORDER BY `id` DESC") or die(mysql_error()); $row_result= mysql_fetch_array($result); echo $row_result['id'];
  16. lol, Ok, so i have a script that pulls it out of one table and inserts it into the other (don't ask why.. it just does.. ) , how would i use mysql_real_escape_string when everything is queried as its being inserted.. EXAMPLE: $result= mysql_query("SELECT * FROM `table`") or die(mysql_error()); $row_result= mysql_fetch_array($result); mysql_query("INSET INTO`table2` ('column','column2') VALUES ('$row_result[column]','$row_result[column]')"); how would i clean it?
  17. So, how would i clean a query that is being copied somewhere else?
  18. I might just be talking rubbish (shot in the dark!), but maybe there is a way to use the Europe/Berlin and enable daylight savings?
  19. This is probably a simple question but my MySQL insert errors out when it encounters content that has a / is there a way to have it ignore it or something?
  20. I have no idea why.. line 65 is this.. $row_flightplan = mysql_fetch_array($flightplan); no clue why... here is somemore code above and below.. .... else { mysql_query("INSERT INTO `flightplans` (....) VALUES (....)"); $flightplan = mysql_query("SELECT * FROM `flightplans` ORDER BY `id` DESC"); $row_flightplan = mysql_fetch_array($flightplan); mysql_query("INSET INTO `flights` (....) VALUES (....)"); mysql_query("INSERT INTO `logs` (....) VALUES (....)"); } .....
  21. ok, with a bit of modding that should work thanks!
  22. i have this number: -006.270000 and i need it to become: -6.270000 the number of 0's may vary, there also may or maynot be the - sign.. any suggestions?
  23. How about a .htaccess Permanent Re-Direct?
×
×
  • 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.