Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
There is no need to make a select and then an update - if you do this on every page, you are taxing your database more than you need to.
-
http://us2.php.net/file_exists file_exists is only for files on your server, it won't (AFAIK) work for URLS (which btw, need to begin with http://) Try get_headers perhaps? http://us2.php.net/manual/en/function.get-headers.php
-
Is that the ENTIRE code of the page? Create just a page with the connection to the DB and the code, and see it then. There must be some other code, or the file is being called 4 times each time or something.
-
In that code you never get $views from the query. You're setting it to 1 each time. Use the code I posted, it will work. If it doesn't, we can go from there.
-
<?php include 'dbconnect.php'; $id = $id; //what? This is repeatedly redundant... mysql_query("UPDATE table SET views=views+1 WHERE id = '$id'"); ?>
-
<? $array=array("param1","param2"); foreach($array AS $el){ if(isset($_POST[$el]) $el = $_POST[$el]; }else{ $el = null; } } ?> Why are you trying to create a function for something simple like assigning a variable?
-
See comments for ( $counter = 0; $counter < 4; $counter++ ) { //Where does $fto_id come & $class_id from? $query = "SELECT * FROM schedule WHERE fto_id = '$fto_id' AND class = '$class_id' AND phase = '$counter'"; // Add me to see if $query is what you really expect: print $query.'<br />'; $result_id = mysql_query($query, $link) or die("Could not read from database: " . mysql_error()); //Add me to see what is the result: print '<pre>'; print_r($result_id); $num_rows = mysql_num_rows( $result_id ); // If rows exist do an update else do an insert if( $num_rows > 0 ) { $query = "UPDATE schedule SET fto_id = '$fto_id', class = '$class_id', phase = '$counter', available = '$phase[$counter]'"; } else { $query = "INSERT INTO schedule VALUES ('$fto_id', '$class_id', '$counter', '$phase[$counter]', NULL)"; } $result_id = mysql_query($query, $link) or die(mysql_error()); }
-
Look up the "select" syntax. gotapi.com is a good site for this stuff. Specifically, you're interested in : Limit and offset
-
Image still caching, or possibly problem with ajax & session?
Jessica replied to Jessica's topic in PHP Coding Help
Hey Barand, I know about that as a fix and I said that in my post I don't like doing that as it makes the URL messy looking. Couldn't there be another way to fix this? -
Image still caching, or possibly problem with ajax & session?
Jessica replied to Jessica's topic in PHP Coding Help
I was testing in Fx. Doesn't the session_cache_limiter affect the session? Not things like images? I was trying to upload a very large file just now, that might be why it was slow. I am heading out so if it is still slow later I'd love to know - I'm using MT so I will yell at them if it's slow! -
Because you're not doing anything with the result. You can't just copy and paste without understanding what you're doing You didn't change the code given to make it work with your code. Does your table actually have a field1 that will equal 'value'? Probably not... There are tons of tutorials on PHP/Mysql so I think you need to read one to find out how to use the $result you got and make it display info.
-
I am having a problem where I suspect images are being cached, despite using the following headers from the PHP.net manual: header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past Here is the page, and the steps to create the problem: http://www.cubedpop.com/create/tags/ It should load a rectangle "tag" with the current timestamp in it. The tag object is stored to the session. Click on Tag Shape and a php page is loaded via Ajax (JS from to Mootools.net) with a bunch of shapes. Click any one of them but the rectangle. This loads a new page via ajax. This page changes the shape of the tag, and saves it to the session. Then it "draws" the image: print '<img src="http://cubedpop.com/create/process/draw/tag/" />'; IF I change this to below, it works perfectly. However, I hate the ugly URL it creates. There has got to be a way to stop the caching! Why do my cache headers not work? print '<img src="http://cubedpop.com/create/process/draw/tag/?t='.time().'" />'; If it is NOT the headers/caching issue, here is more info: Note: I use an htaccess file to redirect all pages to a base file which includes the library files and the session_start(), site-wide constants, etc. Here is the code of the draw tag file: <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past $drawTag = $_SESSION['drawTag']; header("Content-type: image/png"); // Create the image $im = imagecreatefrompng(TAG_SHAPE_IMG_URL.$drawTag->shape->image); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagettftext($im, 14, 0, 50, 50, $black, FONT_PATH.'tahoma.ttf', time()); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> As you can see, the image is not updated when you change the shape. However, if you make the change, then view just the image in your browser: http://www.cubedpop.com/create/process/draw/tag/ The timestamp will update, and the new shape appears. Because the change is made I can tell the session was saved properly. So, this leads me to think the image is caching. Also, if I print_r($_SESSION) on the page which changes the shape and then displays the image, the session contains the correct new shape in it, yet the image is wrong, and the timestamp is old. Help...!
-
I need help with this - I've search and not found any reliable answers. Any email sent from a server is marked as spam - it's not just email sent via PHP so I don't think it's the headers I'm using in the PHP mail. It's also mail sent from the webmail they have set up, using either Horde or Squirrel Mail. Any leads?
-
Thanks I was able to edit that code to do just what I wanted! You rock Andy
-
I have a grayscale image, (just three colors) and I want to use php to apply color to it, so it turns, say, blue. I have a ton of these greyscale images and a lot of colors, so I want to use php to do it when needed instead of doing them all by hand in photoshop. I have done some searching but I'm not even sure what to call this. Any pointers? Turn: Into:
-
Neel, I don't have access to any server with any ASP code to test it, or I would have just tried it. Sounds like this is going to take more time than the client is willing to pay for. Thanks guys.
-
I'm asking if ASP puts information in the session, can PHP access it? So if ASP does this: <% Session("username")="Donald Duck" %> Can I then do <?php $username = $_SESSION['username']; ?>
-
Anyone?
-
I have a client who has a current login script which is written in ASP. She wants me to add a new form to it, and it would need to access the username and password. (I assume they are stored in the session the same way as we would in PHP) Is this even possible? Would I just access the session like usual?
-
function send(){ $time = time(); $sql = "INSERT INTO mail(from, userTo, subject, message, sent) VALUES($this->from, $this->$to, '$this->subject', '$this->message', $time)"; return dbExecute($sql); } 57 is the $sql = line. What am I missing?
-
You could use css to hide extra lines by using line height, em measurements and overflow: hidden
-
[SOLVED] problem with include(http://www.mydomain.com/template.php);
Jessica replied to elias's topic in PHP Coding Help
You can't include urls with query strings. -
looks fine to me. How are you inserting the expiration time? It will help if you make sure all of the time functions are handled on one side or the other. Instead of using now() in mysql, use PHP's time and format it.
-
Most of the results for my username are me, as I use the same username everywhere. The only one that might look to be me but is not is the drunkmenworkhere blog. (that person is weird.)
-
Your server and database might be set to different timezones?