Jump to content

aarchaic

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aarchaic's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello guys. I see there is a few threads on this subject but i have this problem the code looks ok to me but i'm not really up to scratch with functions or classes. this is the error... Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/site/public_html/pfp/magazine/db.php on line 6 :queasy::queasy: here is the code. config.php <?php // ADMIN SETTINGS // define ("ADMIN_PASSWORD", "PASS"); // Admin Password define ("WEBSITE_NAME", "Flash Page Flip"); // Your Website Name // MySQL SETTINGS // define ("HOST","localhost"); // database host define ("USR", "user"); // database username define ("PSW", "pass"); // database password define ("DB", "cms"); // database to use // E-MAIL SETTINGS // define ("MAIL_FROM_NAME","website admin"); // Sender Name define ("MAIL_SENDER_EMAIL","sender@example.com"); // Sender E-mail define ("MAIL_SENDER_USERNAME","sender@example.com"); // Sender E-mail Username define ("MAIL_SENDER_PASSWORD","youremailpassword"); // Sender E-mail Password define ("MAIL_SERVER","mail.example.com"); // Sender Mail Server define ("CHAR_SET","8859-1"); // Mail Character Set Code define ("STF_SUBJECT","Check This Out"); // Tell a Friend Mail Subject define ("STF_LINK","www.example.com"); // Your Publication Link For Tell a Friend define ("LOST_PASSWORD_SUBJECT","Your Login Information"); // Lost Password Mail Subject ?> db.php <?php require_once("config.php"); class db_layer { private $conn; function __construct() { } public function getConnection() { if($this->conn == "") { $conn = mysql_connect(HOST,USR,PSW); mysql_select_db(DB); mysql_query("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';"); $this->conn = $conn; } return($conn); } public function execute_sql($arg_sql,&$arg_result,&$arg_error_msg) { $arg_sql = str_replace(';', ':', $arg_sql); $this->getConnection(); if (!($arg_result = mysql_query($arg_sql))) { $arg_error_msg = "There was a problem With the Database".NL."Error : ".mysql_error().NL.NL; $arg_error_msg .= "SQL = [".$arg_sql."]"; echo $arg_sql1= $arg_sql." ### ".mysql_error(); return FALSE; } else { return TRUE; } } } ?> if comment out the private $conn line it just moves on and gives me exactly the same error on line 11. any insight would much appreciated! thanks
  2. ok after a weekend of struggling i manage to work it out! here is the code... <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button> </form> <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = basename($_FILES['new_image']['name']); $source = $_FILES['new_image']['tmp_name']; $target = "gfx/profilephotos/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "gfx/profilephotos/" . $imagepath; //This is the new file you saving $file = "gfx/profilephotos/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $largeimage=500; //sets the longest side $imgratio=$width/$height; //works out the image ratio and if its a portrait or landscape if ($imgratio>1){ //tests if it is a landscape $newwidth = $largeimage; //sets the longest side for landscape $newheight = $largeimage/$imgratio; //calculate the shortest side for landscape }else{ $newheight = $largeimage; //sets the longest side for Portrait $newwidth = $largeimage*$imgratio; //calculate the shortest side for Portrait } $tn = imagecreatetruecolor($newwidth, $newheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "gfx/profilephotos/med_" . $imagepath; //This is the new file you saving $file = "gfx/profilephotos/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $mediumimage=195; $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $mediumimage; $newheight = $mediumimage/$imgratio; }else{ $newheight = $mediumimage; $newwidth = $mediumimage*$imgratio; } $tn = imagecreatetruecolor($newwidth, $newheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "gfx/profilephotos/thumb_" . $imagepath; //This is the new file you saving $file = "gfx/profilephotos/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $thumbimage=80; $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $thumbimage; $newheight = $thumbimage/$imgratio; }else{ $newheight = $thumbimage; $newwidth = $thumbimage*$imgratio; } $tn = imagecreatetruecolor($newwidth, $newheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: <img src='gfx/profilephotos/".$imagepath."'><br>"; echo "Medium: <img src='gfx/profilephotos/med_".$imagepath."'>"; echo "Thumbnail: <img src='gfx/profilephotos/thumb_".$imagepath."'>"; } } ?>
  3. no i need help cause i really have no idea how to do it. i've been ok doing sessions cookies and database verification. but with images i have no experiences what so ever if some one can just give me some guide lines to how to it i'll give it a try. So if someone can just help me to get started i'll really appreciate it!
  4. I have a script that needs alteration. and since i've never worked with images and php this is a complete nightmare and not really sure how i should approach this. the code is as follows.... ( Found it here http://www.theopensurgery.com/29/php-upload-and-resize-image-script/ ) <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button> </form> <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ if(!file_exists("images")) { mkdir("images" , "0744") or die("Could not create images folder"); die("folder created!"); } $imagename = basename($_FILES['new_image']['name']); $source = $_FILES['new_image']['tmp_name']; $target = "images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "images/sml_" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: <img src='images/".$imagepath."'><br>"; echo "Thumbnail: <img src='images/sml_".$imagepath."'>"; } } ?> this is what i need it to do... 1. large image of 500 pixels on the long side 2. medium image of 195 pixels on the long side 3. the thumb of 80 pixels on the long side. 4 work in an image size checker not larger than 2 meg... thanks for your help
  5. hey guys i have a little issue. I'm working on a site where a person can put some information in about themselves what happens is that once you wrote a nice long block of info and spaced it and so on you click save and it updates to my database. but once you call it back in the website i just get 1 huge chuck of text and you lost all your spacings and formatting you did while writing the info. can anybody please shed some light on how i can over come this?
  6. Hello Guys i'm in need of some major assistance. I'm busy with a website and will need to bring in a Image upload section where people can upload photos to. (max of 6 ) I have very very limited coding knowledge on this. i can program basic functionality and sections of a website. I need a piece of code that can validate a image upload ( max size 2meg/ 2000pixels at the longest size ) then resize the photo to a maximum of 500 pixels with decent quality but not too big to make downloading too long also to create a thumbnail of a maximum of 80 pixels and then read it into a table field seperated by a comma Can somebody please assist me? Thank you very much for your time!
  7. I manage to sort the problem out!!! i just had to add a extra 2 lines to the logged.php code this is how it looks.... <?php //Checks if cookies been set if (isset($_COOKIE['nlgebruiker']) && isset($_COOKIE['nlwagwoord']) && isset($_COOKIE['nltoken'])){ $_SESSION['nlemail']=$_COOKIE['nlgebruiker']; $_SESSION['nlpassword']=$_COOKIE['nlwagwoord']; $_SESSION['nltoken']=$_COOKIE['nltoken']; } // test the if Session or cookie data is valid if ((strlen($_SESSION['nlemail']) == 0) or (strlen($_SESSION['nlpassword']) == 0) or (strlen($_SESSION['nltoken']) == 0)){ header('location: login.php'); } else { if (isset($_SESSION['nlemail']) && isset($_SESSION['nlpassword']) && isset($_SESSION['nltoken'])){ $user=$_SESSION['nlemail']; $pass=$_SESSION['nlpassword']; $token=$_SESSION['nltoken']; $query=("select * from useraccounts where email='$user' and password='$pass' and token='$token';"); $results=mysql_query($query); if ( mysql_numrows($results) <> 1 ) { //test if data is valid //unsets info and redirect back to the logon page. unset($_SESSION['nlemail']); unset($_SESSION['nlpassword']); unset($_SESSION['nltoken']); $_SESSION = array(); // reset session array session_destroy(); // destroy session. header('location: login.php'); } }} ?> Thanks for your input Jackpf
  8. No not yet working with apache and mysql and php on my pc directly.
  9. Unfortunately its doing in firefox and IE
  10. Hello I'm busy building my own website and want to make it more interactive so people can join the site send each other messages look at photos and so. what i've done so far is created a database with a useraccounts table. in this table i have 3 fields i use for authentication for the site. these fields is: Email; Password, Token The code works great that i got so far it registers in the database it authenticates the lot but the problem thats been keeping me busy for the last day and half is the session and cookie logon. my login page has a option with "Remember me" check box. if i logon using the check box it keeps me signed in and working as i want but as soon as i log out and log back in with out the remember me check box clicked and i close the page or the browser it logs me back in and for some reason in my life i cant get it to loose that session data that it will not log in. heres my code that i've done... login.php <?php session_start(); include("includes/database.php"); $today=date("Y-m-d"); if(isset($_POST['aanteken'])) { //checks forms been submitted $gebruiker=$_POST['gebruiker']; $wagwoord=$_POST['wagwoord']; if(strlen($gebruiker) < 1){ //checks if email address been enter $error="Please enter your Email Address."; unset($_POST['gebruiker']); } elseif (strlen($wagwoord) < 1){ //checks if password been enter $error="Please enter your Password."; unset($_POST['wagwoord']); } else { $query=("select * from useraccounts where email='$gebruiker' LIKE 'a%';"); //checks if email does exist in database $result=mysql_query($query); if( mysql_numrows($result) < 1 ) { $error="Email/Password error try again."; } else { $md5pass=md5($wagwoord); // encrypts password $query=("select * from useraccounts where password='$md5pass' and email='$gebruiker' LIKE 'a%';"); // checks if email address and password match $result=mysql_query($query); if( mysql_numrows($result) < 1 ) { $error="Email/Password error try again."; } else { $token="$gebruiker.$today"; // makes a unique token for logging in $token=md5($token); // md5 encryption on unique token if(isset($_POST['onthou'])) { // checks if remember me have been checked $wagwoord=md5($wagwoord); // md5 encryption password $query=("update useraccounts set token='$token', last_login='$today' where email='$gebruiker';"); // updates token and last login date mysql_query($query); // sets cookie data setcookie("nlgebruiker", $gebruiker, time()+60*60*24*100, "/"); setcookie("nlwagwoord", $wagwoord, time()+60*60*24*100, "/"); setcookie("nltoken", $token, time()+60*60*24*100, "/"); header("location:userpanel.php"); // changes page to user info } else { // sets session data if remember me not been set. $query=("update useraccounts set token='$token', last_login='$today' where email='$gebruiker';"); // updates token and last login date mysql_query($query); // sets session info $_SESSION['nlemail'] = $gebruiker; $_SESSION['nlpassword'] = $md5pass; $_SESSION['nltoken'] = $token; header("location:userpanel.php"); // changes page to user info } } } } } ?> <link href="css/ANstyle.css" rel="stylesheet" type="text/css"> <div id="useraccess"> <table align="center" height="250" border="0" width="275"> <form method="post" action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>"> <tr><td colspan="2" height="36"><img src="gfx/register.jpg"></td></tr> <tr><td colspan="2" align="center"><?php echo $error; ?></td></tr> <tr><td colspan="2" align="center"> </td></tr> <tr><td>Email:</td><td ><input type="text" name="gebruiker" size="28" value="<?php echo $_POST['gebruiker']; ?>"></td></tr> <tr><td>Password:</td><td><input type="password" name="wagwoord" size="28"></td></tr> <tr><td align="right"><input type="checkbox" name="onthou" <?php if(isset($_POST['onthou'])) { echo "checked";} ?> ></td><td align="center">Remember me next time.</td></tr> <tr><td colspan="2" align="center"><input name="aanteken" type="submit" value="Login"></td></tr> <tr><td colspan="2" align="center"><a href="register.php" target="_top" name="register"</a></td> </tr> </form> </table> </div> That links to userpanel.php and the i included the logged.php to check the login status. <?php session_start(); include("includes/database.php"); include('logged.php'); ?> <html code continues.....> the logged.php looks like this <?php //Checks if cookies been set if (isset($_COOKIE['nlgebruiker']) && isset($_COOKIE['nlwagwoord']) && isset($_COOKIE['nltoken'])){ $_SESSION['nlemail']=$_COOKIE['nlgebruiker']; $_SESSION['nlpassword']=$_COOKIE['nlwagwoord']; $_SESSION['nltoken']=$_COOKIE['nltoken']; } // test the if Session or cookie data is valid if (isset($_SESSION['nlemail']) && isset($_SESSION['nlpassword']) && isset($_SESSION['nltoken'])){ $user=$_SESSION['nlemail']; $pass=$_SESSION['nlpassword']; $token=$_SESSION['nltoken']; $query=("select * from useraccounts where email='$user' and password='$pass' and token='$token';"); $results=mysql_query($query); if ( mysql_numrows($results) <> 1 ) { //test if data is valid //unsets info and redirect back to the logon page. unset($_SESSION['nlemail']); unset($_SESSION['nlpassword']); unset($_SESSION['nltoken']); $_SESSION = array(); // reset session array session_destroy(); // destroy session. header('location: login.php'); } } ?> if anybody can help me with this i would be grateful!!
×
×
  • 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.