Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. There are 8 arguments to pass to image copy. imagecopy. **Note: you will have to use imagecopy() twice to overlay 2 images. You are getting header errors, due to the errors being output to the screen. The random characters is the output of the image, because of the errors sending the headers before the header call, the image is outputting as HTML. Fix the errors, you will fix the header and the random character isssue.
  2. That means to surround usage in backticks to specify it as a column name. `usage`, or change the name to something else.
  3. Headers MUST come before any output.
  4. Giving a line number will speed up answers. Just a heads up. Here lies the problem. echo '<input type="hidden" name="item_number_'.$num'" value="'.$id.'" />'; //You have missed a period (.)(dot) after $num.
  5. Remove ob_start(); You are not flushing it, neither do you need it, that may be the problem.
  6. Here you go! </div> <!-- end #header --> <div id="page"> <div id="bgtop"> <div id="bgbottom"> <div id="content"> <div class="post"> <div class="title"> <h2><a href="#">Super Rewards </a></h2> </div> <!-- #################### Content Goes Here #################### --> <p class="highlight">NO!!!</p> <!-- #################### Content Ends Here #################### --> </div> </div> <!-- end $content -->
  7. Without table structure, and desired output this will be difficult. This is more MySQL than PHP though. You may have to try that forum.
  8. PayPal has the sandbox.
  9. Safe, yes. Bad coding, yes. What happens when you change your database connection variable to $conn. You have just broken that function. Now not a big deal if the function resides in the current script you are working in. However, what if it resides in a file that was included? In your script though, the global is not even needed, since you are working in a class. $db is a variable of the class, so it can be used as $this->db (and it is).
  10. Or you could use preg_match to get the attributes, and use them: <?php $pattern = '~([href|title|class]+)="([a-zA-Z0-9:/.,; ]+)"~'; $string = '<a href="http://phpfreaks.com" title="Coding Freaks" class="myClass">Don\'t click here, it is addicting</a>'; preg_match_all($pattern,$string,$matches); echo '<pre>' . print_r($matches,true) . '</pre>'; /*output Array ( [0] => Array ( [0] => href="http://phpfreaks.com" [1] => title="Coding Freaks" [2] => class="myClass" ) [1] => Array ( [0] => href [1] => title [2] => class ) [2] => Array ( [0] => http://phpfreaks.com [1] => Coding Freaks [2] => myClass ) ) */ Now you can manipulate them how you wish.
  11. Does your directory structure returned from __FILE__ match up with the directory structure you are passing to file_get_contents?
  12. You could do it with DOMdocument, or with preg_replace. Using preg_replace, you could capture the class, title, and href, then manipulate them how you want them to be added back to the anchor.
  13. You could make it work dynamically, if you made a naming convention for your email txt files. I would suggest either the whole name of the item, or you could specify X number of characters, say 10. So, if you did 10 characters, then your package name: Total Sondheim Seminar Package would have an email file of: ipn_total_sond.txt If you need it longer, just specify, and adjust. Example <?php $tssp = array(); foreach ($arrCart as $cartItem) { $tssp[] = 'ipn_' . str_replace(' ','_',substr($cartItem['item_name'],0,10)) . '.txt'; //this is the text files name: ipn_theFirst10charactersOfTheName.txt } if (!empty($tssp)) { //if tssp is not empty. foreach($tssp as $file) { if(file_exists($file)) { //search the array to see if the files exist. $email = $file; //the first one it finds, set the email variable, and break the loop. break; } } } if(!empty($email)) { //if email variable is set and not empty. ewpp_LoadEmail($email); //load the file. } else { ewpp_LoadEmail("ipn.txt"); //else load the default. }
  14. By searching a column by every word separated by a %, you will get results where all the words are in the column, but not necessarily in a string. You could force it to a string if the user puts the search in quotes. Example <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { //if a post request is made. if(!empty($_POST['search'])) { //if the search is NOT empty. if(strpos($_POST['search'],'"') !== false) { //if the search contains a quote " preg_match_all('~"([^"]+)"~',$_POST['search'],$matches); //match the quote. $quoted_string = $matches[1][0]; //get the match from the array. $quote = "column LIKE '%" . mysql_real_escape_string($quoted_string) . "%'"; //set it to a variable inside a proper formatted query column selection. $_POST['search'] = str_replace('"' . $quoted_string . '"','',$_POST['search']); //remove the quote from the search. } $parts = explode(' ',$_POST['search']);//Split the string on a space. $parts = array_filter($parts); //now filter the array to get rid of empty indexes. $parts = array_map('mysql_real_escape_string',$parts); //escape SQL data. //YOu can use if/else statements to finalize the query string, I used ternary operator. //if the quote is not empty, use it---if the quote and parts are not empty(both) then separate them with OR---if parts is not empty, use them. $sql = "SELECT * FROM table WHERE " . (!empty($quote) ? $quote : NULL) . (!empty($parts) && !empty($quote) ? ' OR ' : NULL) . (!empty($parts) ? "column LIKE '%" . implode('%',$parts) . "%'" : NULL); } echo $sql; //print a proper sql formatted string to the screen. }
  15. Sure, PHP is a programming language that works on the server side, MySQL is a database that resides on a server. Most of the time, they are on the same server, although they don't have to be. PHP is PHP, MySQL is MySQL, many confuse that MySQL is part of PHP, it is not, it has it's own language and it's own functions. MySQL is a relational database, so tables can have relationships. The way your table is set up, is that the rows in your table have a relationship based on the landlord's name. We can use that relationship to get all the data for that landlord, no matter how we start to gather the data. This query: $sql = "SELECTb.city, b.landlord_name, b.landlord_comments FROM $tbl_name AS a JOIN $tbl_name AS b ON a.landlord_name = b.landlord_name WHERE a.id = $id"; does exactly what your TWO queries does. It ask for the row specified by the id, then ties all of the rows in that table to the landlord_name back to the row with the correct id. MySQL JOIN syntax (MySQL manual)
  16. You should be able to get everything after the question mark (?) with: $_SERVER['QUERY_STRING']; SERVER variables
  17. Yes, you can, but you also realize that you will not see that the session is unset until the next page load, as you already have the contents. Try this test. <?php //syntax highlighting public function get(){ // Is something set? if(isset($_SESSION['currentMessage'])){ // Yes, into a variable! $message = $_SESSION['currentMessage']; // Unset the session for later use. unset($_SESSION['currentMessage']); // Return the message. $f = "<p style=\"color:green\">"; $f.= $message; $f.= "</p>"; $f .= $_SESSION['currentMessage']; //You should get an undefined index notice, because currentMessage is not set. return $f; } // No, Return false then to stop an error appearing. return false; }
  18. Only use one query, also check to make sure id is set and not empty. <?php //syntax highlighting. if(!empty($_GET['id'])) { $id = (int)$_GET['id']; } else { $id = 0; } $sql = "SELECTb.city, b.landlord_name, b.landlord_comments FROM $tbl_name AS a JOIN $tbl_name AS b ON a.landlord_name = b.landlord_name WHERE a.id = $id"; I believe that query will work, it hasn't been tested though.
  19. Variables do not need to be defined before being initialized, but they do need to be defined before being called for use. You are trying to use a variable called text, without it being set. Without the code, there is no way to help you though. $str = 'This is a string.'; //defined if($text) { //text is not defined, and you will get a notice. $text = 'More text.'; //text is now defined. } if(isset($fell_down)) { //fell down is not defined, but isset will keep it from throwing a notice. (empty will too).
  20. The correct argument list for mail is: <?php //syntax highlighting mail($to,$subject,$message,$headers); //from is a header. mail
  21. Before you do anything, make sure your database follows the normal form. . Once you have passed that, then you can plan how your script will act, and you should be able to pull everything you need with one query.
  22. Can't believe that script doesn't have a parse error: <?php //syntax highlighting. if($username && $email && $age && $location && $duration && $griefed && $access && $builder && $fill){ $to = "dtoyee@dawncraftmc.com"; $from = '$email'; $subject = "Creative World Application" ; $message = "Username: $username /n" . "Email: $email /n" . "Age: $age /n" . "Location: $location /n" . "Duration on the server: $duration /n" . "Ever griefed: $griefed /n" . "Access to the new world: $access /n" . "Are you a good builder: $builder /n" . "Anything else that we should know: $fill /n" . //<- You need to remove the . (period) and place a ; (semicolon). mail($to, $from, $subject, $message);
  23. So, you are forcing the server to serve the PHP file as a HTML static file. You are getting the desired results that you asked for. If you want PHP parsed as PHP, then do not force the type to HTML.
  24. If you are using javascript, why not use a pop up (div) populated via AJAX. Then you would have no worry about page refresh, and you can easily close it at any time via javascript and the div id. As far as the . You should have a title element in the head of the document. If it is missing, the browser shows the link instead.
  25. That is not a real good idea, and I am not sure why you cannot hard code a login form. To answer you question though, you can use eval.
×
×
  • 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.