Jump to content

johnnyk

Members
  • Posts

    126
  • Joined

  • Last visited

Everything posted by johnnyk

  1. ...um, sorry people. It actually was working fine... I saw something coming up on the page and got confused and thought it was whats in the if... ...sorry to waste your time I'm an idiot. But it's late at night, so you can't blame me too much.
  2. It only gets screwed up in a certain script of mine. If I isolate the if into its own php script it works fine. Is there any possibility that somehow the rest of my script is affecting the if? Is there any possibility it's a really strange bug? Is there any possibility my host is to blame? Something is cursed up here, but I have no idea what. Where's the smiley for "Head is about to explode"? Damn new forum.
  3. PHP Version 5.1.4 This is weird and annoying and pissing me off. if('2006' == '2005'){   echo "<div class=\"class\">\n";   echo "<h5 class=\"class\">text</h5><.br />\n";   echo "</div>\n"; } (I added the . to the <.br /> because this new forum is evil) The if executes. Am I missing something obvious? Honestly, what the curse? This is the strangest PHP related problem I've ever had. Honestly, at this point if you told me it was executing because I'm not standing on my head I would believe you because I can't find any other reason. I had another weird problem the other day. MySQL kept saying there was an error in my SQL syntax when there wasn't. I even posted it on here and someone verified it was fine with the version of MySQL I was using, but MySQL kept bitching. So my question is, why do PHP and MySQL hate me? Or maybe my question is, why am I going crazy? This is like a PHP nightmare. Things are just going crazy for absolutely no reason at all. AHH!!!!
  4. Tried both and neither works. If it makes any difference, and I don't think it does, the result (as well as the query and what not) is in a function and $date is passed to the function. This is weird and annoying.
  5. 5.0.21 I'm not crazy, right? Isn't the syntax correct?
  6. I'm getting this message: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(`datetime`) = '2006-06-28'' at line 1 Here's the result: $result = mysql_query("SELECT *, DATE_FORMAT(`datetime`, '%W, %M %D') AS `date`, DATE_FORMAT(`datetime`, '%l:%i %p') AS `time` FROM `table` WHERE `a` IS NULL AND DATE(`datetime`) = '$date'") or die(mysql_error()); //$date = 2006-06-28 If I remove the [b]AND...")[/b], it work's fine. So it's saying there's a problem with: AND DATE(`datetime`) = '$date' What's wrong with the syntax? It looks good to me.
  7. I'm bad with terminology and what not, so if I confuse you and sound like an idiot, I warned you: Is it possible to pass the search of a preg_replace() to a function via the replacement? What I mean is something like this: [code] <?php function func($text){    echo $text . ' is today's date'; } $string = 'April 15, 2003'; $pattern = '/(\w+) (\d+), (\d+)/i'; $replacement = func('$1 $2, $3'); echo preg_replace($pattern, $replacement, $string); ?> [/code] I want it to echo "April 15, 2003 is today's date" but it's echoing "$1 $2, $3 is today's date". Yes, I know that I could just add "is today's date" to the replacement, but that's not the point. Ignoring what the function does, is it possible to use it via the replacement? It's a bad example but I think you understand what I mean. Any ideas?
  8. My bad. Do something like this: $a = $_POST['client_email']; $result = mysql_query("INSERT INTO $tableName (confirm_code, email) VALUES($confirmCode, $a)");
  9. But that doesn't affect MySQL's NOW() I'm talking about [a href=\"http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/tim...ne-support.html[/a] How do I set MySQL's timezone in PHP. The above page says you should use mysql> SET time_zone = timezone; but how do you do that in PHP? Also, what is the difference between that and mysql> SET GLOBAL time_zone = timezone;
  10. $result=mysql_query("INSERT INTO $tableName (confirm_code,email) VALUES($confirmCode,$_POST['client_email'])");
  11. How would I set something like a timezone or mode in MySQL with PHP? Mysql.org says to use something like mysql> SET time_zone = timezone; But what do you do for PHP? I tried mysql_query("SET time_zone = timezone"); but that didn't work. While we're at it, what does it mean to set something as GLOBAL?
  12. But wouldn't it be easier to upload the actual image to the database? Isn't that what blob is for?
  13. [!--quoteo(post=388209:date=Jun 26 2006, 04:44 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Jun 26 2006, 04:44 PM) [snapback]388209[/snapback][/div][div class=\'quotemain\'][!--quotec--] Because they don't know what they are doing. [/quote] Hah. Alright, thanks.
  14. How do you run the cron jobs? I know my host lets me set them up but I think they only let it run once a week. Is there any other way to set one up?
  15. You know how when someone submits their email address for something you should send them a verification email with a code or whatever? I think I understand how [i]that[/i] works. Something like you send them an email with a uniqid() and store that uniqid() in your db with their email and then when they verify compare the email and the uniqid(), right? Well, then what do you do about people who never verify? How would you have the row with their email and uniqid() automatically deleted? Do people use cron jobs or something to delete them after a certain amount of time has gone by?
  16. So if I just need one unique column, should I use primary key? Also, I saw a tutorial online that defined one column as primary key and unique id. It looks like this: [code]create table myBlobs ( blobId int auto_increment not null, blobTitle varchar(50), blobData longblob, blobType varchar(50), primary key(blobId), unique id(blobId) );[/code] [a href=\"http://www.devarticles.com/c/a/MySQL/Blobbing-Data-With-PHP-and-MySQL/1/\" target=\"_blank\"]http://www.devarticles.com/c/a/MySQL/Blobb...HP-and-MySQL/1/[/a] Why would they define it as primary key and unique?
  17. It's a MySQL date function. It returns the current date in YYYY-MM-DD format. [a href=\"http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.1/en/dat...-functions.html[/a] If you need a unix timestamp, use UNIX_TIMESTAMP() instead. (same page, lower down)
  18. [!--quoteo(post=387931:date=Jun 26 2006, 02:15 AM:name=BigMike)--][div class=\'quotetop\']QUOTE(BigMike @ Jun 26 2006, 02:15 AM) [snapback]387931[/snapback][/div][div class=\'quotemain\'][!--quotec--] Would the name 'post' be the database name or would it be a table in the database itself? [/quote] Neither. "post" is just the name of the variable you are passing to php. In adamwhiles' example, he used: [a href=\"http://www.yourdomain.com/posts.php?post=5\" target=\"_blank\"]http://www.yourdomain.com/posts.php?post=5[/a] echo $_GET['post']; //5 But you could use whatever name you want and whatever value you want. For example: [a href=\"http://www.yourdomain.com/posts.php?name=Audin\" target=\"_blank\"]http://www.yourdomain.com/posts.php?name=Audin[/a] echo $_GET['name']; //Audin If you want help with your database, could you show us some of your php code?
  19. So do you think I should put the image filename in the database along with the info that goes along with the image (title and category and what not)? I googled and people were talking about that. I guess it would work pretty well. But just out of curiosity, what's so bad about uploading a file to a database? Isn't that what blob is for?
  20. So I'm storing an images in a database. At some point, I'm gonna need thumbnails of these images. So my questions is this: Assuming speed and database size are of equal importance to me, would you suggest - 1. using PHP's image functions to create a thumbnail and insert it into the database or 2. only inserting the fullsize image into the database and then creating a thumbnail from a query of the fullsize. In option 2, the page that's querying the fullsizes would be querying about 25 images.
  21. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] <?php <div class="fixcenter"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr class="header"> <td valign="middle"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="770" height="200" align="top"> <param name="movie" value="/images/header.swf"> <param name="quality" value="high"><param name="LOOP" value="false"> <embed src="images/header.swf" width="790" height="200" loop="false" align="top" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object> </td> </tr> </table> ?> [/quote] Your page doesn't have any actual PHP in it. All it is is HTML with a "<?php" before it and a "?>" after it. You could do one of the following to make it display correctly, without the warning: 1. Eliminate the <?php and ?>. Since there is no PHP contained within them, they serve no purpose [code]<div class="fixcenter"> <table border="0" width="100%" cellspacing="0" cellpadding="0">   <tr class="header">     <td valign="middle"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="770" height="200" align="top">             <param name="movie" value="/images/header.swf">             <param name="quality" value="high"><param name="LOOP" value="false">             <embed src="images/header.swf" width="790" height="200" loop="false" align="top" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>     </td>   </tr> </table>[/code] 2. Use echo to display the HTML [code]<?php echo "<div class=\"fixcenter\">\n"; echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n"; ... echo "</table>\n"; ?>[/code] The second one prints the HTML using PHP. The end result is exactly the same as the first one, making it pointless (unless you plan on adding PHP to the script later). If you echo a string ("<div class=\"fixcenter\">\n"), you have to escape the quotes that contain the string. So for this, since the string is contained in double quotes you have to escape all double quotes. That means you have to put a \ in front of any double quotes. \n is a line break. If you don't use that, all the HTML will be on the same line when the page is loaded.
  22. The whole mypage.php, with the includes.
  23. What's the difference between UNIQUE and PRIMARY KEY?
  24. I'm having trouble setting and retreiving the MySQL mode. Based on what I read at mysql.org, this is what I wrote: [code] <?php mysql_connect(blah blah blah); mysql_select_db(blah blah blah); mysql_query("SET GLOBAL sql_mode='strict_all_tables'"); $result = mysql_query("SELECT @@global.sql_mode;"); //also tried without semicolon, no difference $row = mysql_fetch_array($result); print_r($row); ?> [/code] I'm getting "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in page.html" Also, what is the difference between GLOBAL and SESSION. If I'm gonna be setting the mode after each connect, which one should I go with? Or does global eliminate the need to set the mode after every connect? Any help would be appreciated. Thanks much.
  25. [!--quoteo(post=386692:date=Jun 21 2006, 09:51 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 21 2006, 09:51 PM) [snapback]386692[/snapback][/div][div class=\'quotemain\'][!--quotec--] This would depend upon the servers OS setting I would think. [/quote] Is there a way to find out if my server uses DST on MySQL without waiting until the fall? My host outsources and asking them won't solve anything.
×
×
  • 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.