Jump to content

mhoctober

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mhoctober's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Experts... I want to check for the existence of a cookie, and if its not set, set it. I am getting this warning as I load my code in a browser...any ideas?? Warning: Cannot modify header information - headers already sent by (output started at /home2/seeasale/public_html/updatestats.php:4) in /home2/seeasale/public_html/updatestats.php on line 14 Page Loads : 15 Here is the code... <html> <body> <?php if (isset($_COOKIE["ck"])) { //echo "Cookie Set"; } Else { //echo "Cookie Not Set, Setting Cookie and Updating Counter"; //Line 14 follows... setcookie ("ckBeenHere", time()+43200); // will expire in 12 hours   $i=0; $pageVisited =  $_SERVER['PHP_SELF']; $dbh=mysql_connect ("localhost", "****", "****") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("seeasale_db");  $query="SELECT * FROM tblCounter where fldURL='$pageVisited'"; $result=mysql_query($query)or die (mysql_error()); $num=mysql_numrows($result); echo; if ($num==0) // page has never been visited before by anyone! { $query = "INSERT INTO tblCounter(fldURL,fldCount) VALUES ('$pageVisited',1)"; mysql_query($query) or die('There is a problem: ' .mysql_error()); } else { $upCounterByOne=mysql_result($result,$i,"fldCount")+1; $query = "UPDATE tblCounter SET fldCount = '$upCounterByOne'WHERE fldURL='$pageVisited'"; $result=mysql_query($query)or die (mysql_error()); echo "<center>"; Echo "Page Loads : "; echo $upCounterByOne; } } ?> </body> </html>
  2. Grae.... do you know what line the code is failing on? You may have to write some 'Echos' to determine exactly what line of code is causing the error. It would also help if you could tell us exactly what the error reads.
  3. Thanks again....now I think I'm getting close to the solution!! I am no longer getting an error message but the fldExpiryDate in the table is reading 0000-00-00 here is the revised code snippet.... $num=mysql_numrows($result); $adDurationInDays=$_POST['frmAdDisplayFor']*7; $expires=mysql_result($result,$i,"fldDateCreated")+$adDurationInDays; echo "Weeks ".$_POST['frmAdDisplayFor']."<br>"; echo "Days ".$adDurationInDays."<br>"; $query = "Update tblPeople SET fldExpiryDate='$expires' where `fldTransActionNumber` = $transNum"; I'm still suspecting that I need to do some further work with the variable $expiry before I can store its values in the fldExpiryDate database field. Thanks for the help
  4. Karma - thanks for the suggestion...which I have tried and still get the same error... "There is a problem: 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 'where `fldTransActionNumber` = 10018' at line 1" Any further ideas?
  5. Experts... I have a start date in a database (fldDateCreated) and wish to add a number of days to it to calculate and store an end date in the database. The number of days to add to the start date is determined by the value that a user has selected from a form drop down field (frmAdDisplayFor) //Code Snippet Start $adDurationInDays=$_POST['frmAdDisplayFor']; $expires=mysql_result($result,$i,"fldDateCreated")+$adDurationInDays; $query = "INSERT INTO tblPeople(fldExpiryDate) VALUES ('$expires') where 'fldTransActionNumber' = $transNum"; mysql_query($query) or die('There is a problem: ' .mysql_error()); //Code Snippet End This is the error message that I am getting when I run the code above... "There is a problem: 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 'where 'fldTransActionNumber' = 10016' at line 1" I'm guessing that I have to do some further work with the variable $expires to convert it to a date before I can insert the value it holds into the table.  Any ideas? Many thanks in advance....Mike
  6. Experts... I have users upload files (gifs, jpegs etc..) via a form and code that remanes these files, creates a specifically named folder and stores the files therein! I also have code that can then create A. a thumbnail and B. a smaller version of the original file for viewing when the thumbnail is clicked What I'm missing is code that 'links' the two together. So - I'm looking for a way to... 1. cycle through all the files in a known folder 2. pass each file to code that creates the thumbnail and reduced file size file - that will create 1 thumbnail and 1 reduced file from each original 3. delete the original files in the folder once 1 & 2 have completed succesfully Any ideas?
  7. Searched the archives guys but cant find anything on the following... this code snippet ... <?php session_start(); setcookie("cookieTransNum", $_POST['frmTransNum']); echo 'Passed Form Value :'.$_POST['frmTransNum']; echo '<br>'; echo 'cookieTransNum :'.$_COOKIE["cookieTransNum"]; Produces this output .... Passed Form Value :10312 cookieTransNum : ie. it would appear that the cookie has not been initialised with the value passed from the form. However later in the code, and without repeating anything that would place a value into the cookie, I refer to the same cookie and it appears to be populated with the value passed from the form? Is my expectation that the cookie will be initialsed with the form value in the first code snippet incorrect? Do cookies have 'scope' ? Many thanks....
  8. [!--quoteo(post=370975:date=May 3 2006, 01:01 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 3 2006, 01:01 PM) [snapback]370975[/snapback][/div][div class=\'quotemain\'][!--quotec--] A much easier way of doing this would be to use the [a href=\"http://www.php.net/glob\" target=\"_blank\"]glob()[/a] function: [code]<?php $chk_files = glob('myfiles/12334*.jpg'); if (emtpy($chk_files)) echo 'No files found'; ?>[/code] Ken [/quote] Fantastic ! Works a treat ! Thank God for this forum!
  9. All, my users load images, which I store and partly rename - I add a number to the front of the image name eg. myboata.jpg and myboatb.jpg become for instance 12334(1)myboata.jpg, 12334(2)myboatb.jpg etc... I then want to search for all instances of files that commence with 12334 and am trying the following... $pathAndFile = "myfiles/12334*" if (file_exists($pathAndFile)) { echo "The file exists"; } else { echo "The file does not exist"; } in the folder myfiles there are files that begin with 12334, but the message I get back from the If statement is telling me that "The File Does Not Exist" I have also tried $pathAndFile = "myfiles/12334*.*" and get the same result. Is it legal to use wildcards in this way with the file_exists function? If not - does anyone have any idea how I can serach for files where only the first 5 characters of the filename will ever be known? Many thanks..
  10. Guys... I am attempting to test for the existence of a cookie and take appropriat actions...however, this code ALWAYS displays "Cookie Set" when I load it into my browser. I an attempt to have it execute the Else section I have... - changed the name of the cookie on the If line - deleted cookies via IE But alas - its always displaying "Cookie Set" is there something I am missing here? <?php if (!isset($_COOKIE["ckBeenHere"])) { echo "Cookie Set"; } Else { echo "Cookie Not Set, Setting Cookie and Updating Counter"; setcookie ("ckBeenHere", time()+43200); // will expire in 12 hours }
  11. DragonGamer... the folder that the file is being uploaded to - check permissions. I have seen this error occur when permissions on the folder on the server are not set correctly.
  12. All.. I'd like a .htm page to contain php script that can detect the file name of the current loaded page.... eg if a user clicks a link that loads the following page ... www.myhost.com/12345.htm I'd like 12345.htm to contain code that is able to extract the /12345.htm for storeage in a table or echo to the screen etc.... I have been playing around with <?php $url1=$_SERVER['REQUEST_URI']; echo $url1; ?> which works fine but when I attempt to encapsulate this in html and save and then load it as a .htm file the only output I get is "This is a test file" <html> <body> This is a test file <?php $url1=$_SERVER['REQUEST_URI']; echo $url1; ?> </body> </html> Am I missing something simple!!!??
  13. Thanks! That looks like it will do the trick. To reference the forms variable I was simply using... $first, $last etc... and not $post['first'] Strange that this has only become a problem since we have migrated the site to a new server. Maybe the new server has an older version of php?? That being the case I wonder how many slices of code I'm going to have to hack!!! Thanks again... Mike [!--quoteo(post=352588:date=Mar 7 2006, 02:52 PM:name=XenoPhage)--][div class=\'quotetop\']QUOTE(XenoPhage @ Mar 7 2006, 02:52 PM) [snapback]352588[/snapback][/div][div class=\'quotemain\'][!--quotec--] Code! We need code! :) It *sounds* like the variables are being passed into the script but you're losing them somewhere in there.. Without seeing the source it's gonna be hard to determine what you're doing. Simply put, the variables submitted wind up in 2 of 3 places. If you use a GET method on the form, the $_GET[] hash is populated with the information. If you use POST, then $_POST[] is populated. In both instances, $_REQUEST[] is populated. So, if you submitted a form using a POST method, and you have a username and a password field, you can access the data like this : [code] $username = $_POST['username']; $password = $_POST['password']; or $username = $_REQUEST['username']; $password = $_REQUEST['password']; [/code] And please, code responsibly. Sanitize that data. Don't let that evil skript kiddy hack you! [/quote]
  14. All, I have a .htm form that collects and submits data to a .php file, which connects to a backend mySQL db and inserts the user data, well - thats what its supposed to do!! I have verified that the insert statement in the .php file is working fine (to test it I temporarily hard coded some values into it and these were inserted into the backend mySQL table OK). For some strange reason all the data that the user is entering into the form seems to be forgotten! Further testing results : The key field in the mySQL database is set to auto increment, which it does every time the user completes the forms and clicks submit - but no user data is getting stored in the table. I believe the problem lies somewhere in the form as I have tried echo $first in the .php file and nothing is output to the screen. Any ideas?
×
×
  • 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.