Jump to content

bulrush

Members
  • Posts

    185
  • Joined

  • Last visited

    Never

Everything posted by bulrush

  1. I ended up creating dynamic images with the image library of PHP. It works.
  2. In HTML there are named entities, like &. But I hear there are more entities which are defined with a number. - What is the proper name for these things? - Where can I get a list of the values and what they represent? - Will they display in all major browsers? Thanks.
  3. $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); I'm not sure the <> around $EmailFrom conforms to email standards. I've never received an email like that, with less than or greater than in the From field. And are you sure you need the "From:" in that string also? The To: field doesn't have "To:". EDIT: Aha. This web page says the From address looks ok. http://us2.php.net/manual/en/function.mail.php
  4. I added delimiters (slashes) to preg_match. Removed slashes from preg_replace, 2nd param. $name = $ds['nickname']; if (preg_match('/[^A-Za-z0-9]/', $name)) { $func = preg_replace ( '/[^A-Za-z0-9]/', '', $name); $name = $func; return $name; }else{ return $ds['nickname']; }
  5. Notice I added the 2 slashes in quotes in the 2nd parameter of preg_replace. The slashes are delimiters and are needed in the 1st and 2nd parameters. $name = $ds['nickname']; if (preg_match('[^A-Za-z0-9]', $name)) { $func = preg_replace ( '/[^A-Za-z0-9]/', '//', $name); $name = $func; return $name; }else{ return $ds['nickname']; }
  6. So GMT time does not have Daylight Savings Time like the US does in some areas?
  7. I don't think my Mysql server is storing the GMT time, I think it is storing the time local to the server in California. I'm in Michigan. But I see what you are saying. Thanks.
  8. Perhaps I can do this another way. I have my 'lastlogin' as an SQL 'datetime' type field. Is there a PHP function which returns the local time which can be stored in this field type? Or is there a way I can get the server time and just add 3 hours using PHP?
  9. And so the DELETE statement would be similar, like this? DELETE FROM group RIGHT JOIN parts USING (grid) RIGHT JOIN features USING (grid) WHERE group.grid IS NULL
  10. I have a parent table called "group" where the key is an auto increment field called "grid". It is linked to child tables "parts" and "features", which both store the "grid" value in a field called "grid", linking them to the "group" table. How do I find records in the "parts" and "features" tables where the record in "group" (the grid value) no longer exists? (Due to a possible bug, perhaps.)
  11. In my PHP app, whenever a person logs in, I store the current date and time in the 'user' table in the 'lastlogin' column, which is a DATE type. Here is my SQL statement: $query = "UPDATE user SET numlogin=".$n.", ". "lastlogin=NOW() ". "WHERE userid=".$_SESSION['myuserid'].";"; I also increment the number of logins, just for fun. However the NOW() SQL function is storing the server time (I believe). How can I get it to store my local time? I want to add 3 hours to the time I'm getting from NOW(). Also, my American city does Daylight savings time, so the difference will sometimes be 3 hours, sometimes 4 hours. How can I account for that? Thanks.
  12. Thank you! Thank you! It works! I keep noticing that when I upload my new php file to the server, then click Refresh on my browser, that the new PHP file is not always executed. I have to actually go back to a different PHP file (like the main menu) then enter my changed php file. That may have been one of my problems.
  13. Thank you. 1) I do not have access to the PHP.INI file, we rent space on a commercial PHP server. 2) I will do some testing by going directly to graybox1.php?txt=[N]. So I have that syntax right, at least?
  14. Hm. I see what you mean. graybox1.php may not be executed (though I don't get errors when I run my main script which calls it), so how do I get this working? My <img> tag is created, but no image is displayed. Instead I get the alt text being displayed. crError simply displays an error. Here is it's function. //==================================================== function crError($func, $myerr, $bdie=false) /* Display error, set $b to true to die. $func=function name, must be passed in from calling program. $myerr=error message $bdie=true to die after the error. */ { $msg=mysql_error(); echo '<p style="font-weight:bold;color:#FF0000">ERROR in '.$func.':<br/>'.$myerr.'</p>'; if ($bdie) { die(); } return; }
  15. Just after the WHILE begins, do this: $message=""; You are never initializing $message, that could be the problem. $headers is initialized, but $message is not.
  16. Well I tried your suggestion and this is what I got in the <img> tag. <span class="indent2order" ><img src="graybox1.php?txt=[C]" alt="graybox1"> Option C, add $19 list</span><br/> Here's my graybox1.php file: <?php //require_once('connectvars.php'); /* Create and display gray box in img tag. Text can only be 1 character. Return True on success, false on failure. */ { $width=50; //pixels $height=50; $txt=$_GET['txt']; $txt=str_replace('[','',$txt); $txt=str_replace(']','',$txt); if (strlen($txt)==0) { $msg='Text must be one character.'; crError(basename($_SERVER['PHP_SELF']).' line '.__LINE__,$msg,true); } if (strlen($txt)>1) { $msg='Text can only be one character.'; crError(basename($_SERVER['PHP_SELF']).' line '.__LINE__,$msg,true); } $img=imagecreatetruecolor($width,$height); //Set gray background with black text. $bg_color=imagecolorallocate($img,120,120,120); //Gray $text_color=imagecolorallocate($img,0,0,0); //Black //Fill background. imagefilledrectangle($img,0,0,$width,$height,$bg_color); //Draw the letter. imagettftext($img,18,0,5,$height-5,$textcolor,'timesbd.ttf',$txt); header("Content-type: image/png"); imagepng($img); //Output image. //Clean up. imagedestroy($img); ?> I noticed the <img> tag is being generated, but the actual image is not, so the alt text is displayed instead.
  17. I don't use GET. Could you help me with the format of the src attribute? Would it look like this? $new='<img src="graybox1.php?txt='.$ltr.'" alt="graybox1">';
  18. Earlier this week and last week I posted a question. I needed to display a single letter with a gray background, so I used the CSS background-color style. This displayed fine on the screen but didn't print because browsers, by default, do not print backgrounds. My newest idea is to generate dynamic images with a single black letter on a gray background, but I'm having problems. The image needs to be returned by a function, and when I return the image via the header() function (inside my custom function) I get an error "Cannot modify header data." So there must be another way to return this image via my function. Here is my function so far in my included file called crutil.php: //==================================================== function crGraybox1($txt) /* Create and display gray box in img tag. Text can only be 1 character. Returns: nothing */ { $width=50; //pixels $height=50; $txt=str_replace('[','',$txt); $txt=str_replace(']','',$txt); if (strlen($txt)==0) { $msg='Text must be one character. Text='.$txt; crError(basename($_SERVER['PHP_SELF']).' line '.__LINE__,$msg,true); } if (strlen($txt)>1) { $msg='Text cannot be more than one character. Text='.$txt; crError(basename($_SERVER['PHP_SELF']).' line '.__LINE__,$msg,true); } $msg='crGraybox1: letter is '.$txt; crDebug($msg); $img=imagecreatetruecolor($width,$height); //Set gray background with black text. $bg_color=imagecolorallocate($img,120,120,120); //Gray $text_color=imagecolorallocate($img,0,0,0); //Black //Fill background. imagefilledrectangle($img,0,0,$width,$height,$bg_color); //Draw the letter. imagettftext($img,18,0,5,$height-5,$textcolor,'timesbd.ttf',$txt); header("Content-type: image/png"); imagepng($img); //Output image. //Clean up. imagedestroy($img); return; //crGraybox1 } In my main program code, the user will indicate a gray box by using an ASCII string that looks like this "[N]". This indicates a capital N in a gray box. I need to replace that with an image tag. The string I am modifying is stored in $ot. It might have a [N] string in it. If it does, it needs to display an image of that letter in a gray box. if (ereg('\[([A-Z0-9])\]',$ot,$regs)) { $ltr=$regs[0]; $msg='ltr='.$ltr; //DEBUG crDebug($msg); $new='<img src="'.crGraybox1($ltr).'" alt="graybox1">'; $ot=preg_replace('/\[[A-Z0-9]\]/',$new,$ot); //gray box } Any ideas? p.s. crDebug($s) simply prints a debugging message in a different color. It' doesn't do anything else.
  19. Can I delete multiple records with one DELETE statement? Like this: DELETE FROM table WHERE id=1 or id=2; I guess my alternative is, can I execute 2 delete statements in one PHP query command? $query="DELETE FROM table WHERE id=1; "; $query.="DELETE FROM table WHERE id=2; "; $result=mysqli_query($dbc,$query);
  20. Thank you for your tips. I will use <thead> and do the other tips as well.
  21. Yup. My IP at work is the same all the time. But if I want to do some work from my home PC, my home PC IP is always changing, so I wouldn't be able to do work if someone blacklisted all IPs but our work IPs.
  22. Aha. It's under "Profile Info, Show Posts". Thanks.
  23. Yes, this util.php include file is included in other php files which have an HTML tag. But sometimes the util.php is included BEFORE the html tag. Perhaps my php files are structured incorrectly. I got my structure from the book I just read: "Headfirst PHP and Mysql." This is how they structure their files, and how mine are structured: <?php session_start(); if (isset($_POST['submit'])) {//process user form... } <?php session_start(); ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Online Entry Main Menu</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> (do stuff here including constructing input form.) </body> </html>
×
×
  • 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.