Jump to content

mem0ri

Members
  • Posts

    110
  • Joined

  • Last visited

    Never

Everything posted by mem0ri

  1. I'm running a PHP5 site with a MySQL 4.1 database (yea, I'm asking the provider to update it to 5+)... ...I've got several INSERT, SELECT, UPDATE, etc. statements working great through my database classes--so we know the PHP isn't the problem... I have a particularly long SQL statement: $q = "INSERT INTO rentunit (id, name, region, position, rescom, price, prims, kowner, birth, ptype, active, lease, ishout, iauto, interval, t1, t2, t3, t4) VALUES ('$kobj','$sobj','$sregion','$vpos',0,$price,$prims,'$kowner',$birth,$ptype,0, 0, $shout, $auto, $interval, $t1, $t2, $t3, $t4) ON DUPLICATE KEY UPDATE name='$sobj', region='$sregion', position='$vpos', price=$price, prims=$prims, kowner='$kowner', ptype=$ptype, lease=0, ishout=$shout, iauto=$auto, interval=$interval, t1=$t1, t2=$t2, t3=$t3, t4=$t4"; That is acquiring proper information (I've done a die($q) to read what it translates into): INSERT INTO rentunit (id, name, region, position, rescom, price, prims, kowner, birth, ptype, active, lease, ishout, iauto, interval, t1, t2, t3, t4) VALUES ('objectvalue','Name','Region ','positionvalue',0,1,50,'uservalue',2007-03-08 17:12:27,0,0, 0, 1, 1, 604800, 1, 2, 3, 4) ON DUPLICATE KEY UPDATE name='Name', region='Region ', position='positionvalue', price=1, prims=50, kowner='uservalue', ptype=0, lease=0, ishout=1, iauto=1, interval=604800, t1=1, t2=2, t3=3, t4=4 The table: id-->VARCHAR40 name-->VARCHAR100 region-->VARCHAR25 position-->VARCHAR15 rescom-->TINYINT1 NULL price-->INT5 prims-->INT5 NULL kowner-->VARCHAR40 sugprice-->INT5 NULL birth-->DATETIME death-->DATETIME NULL ptype-->TINYINT1 active-->TINYINT1 lease-->INT11 NULL ishout-->TINYINT1 iauto-->TINYINT1 interval-->INT8 t1-->INT7 NULL t2-->INT7 NULL t3-->INT7 NULL t4-->INT7 NULL The mysql_error() 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 'interval, t1, t2, t3, t4) VALUES ('055bbe47-7df4-7037-acab-10eae649da73','CED Re' at line 1 Help? Been wrackin' my brain for over an hour on just this one problem.
  2. I would like to thank fert for taking so much time to enlighten me with his well-thought out reply... ...the problem...in case anyone was actually wondering...was that my $user->getnumrows command was supposed to be $user->getnumrows() No, session_start() does not need to be at the top of the page before everything and yes, it can be instantiated in a class.
  3. So you're telling me that ABSOLUTELY NOTHING can come before the session_start()? As in...I can't include files...or start a class that initializes by calling session_start?
  4. Just as a start, yes, I have searched these forums through previous session topics just to make sure I wasn't creating needless spam. Situation: All of my user-data is maintained by a PHP Class function called 'initialize: class initialize { private static $sql; private $userid; private $getuser; public function __construct($live=TRUE) { if(self::$sql == NULL) self::$sql = new MySQL; if($live == TRUE) { session_start(); if($_SESSION['userid'] != NULL) { echo("Session Recognized."); $this->userid = $_SESSION['userid']; $user = self::$sql->fetch("SELECT * FROM user WHERE id = ".$this->userid); if($user->getnumrows != FALSE) $this->getuser = $user->getrow(); else { echo("User Authentication Failed"); $this->userid = NULL; $_SESSION['userid'] = NULL; } } else $this->userid = NULL; echo("USER ID: ".$this->userid); } } //...continues with other methods/functions. I am running this class on an index.php page with a CSS tab-strip. I can log-in to the index page just fine, but when I try to 'reload' the page through navigation the tab-strip, I lose all session information and am kicked out to the login screen again... ...I'm a bit baffled honestly... ...here is the initialization of the index page include("PHPClasses.php"); $action = @$_GET['action']; $tab = @$_GET['tab']; if(!$tab) $tab = "units"; $user = new initialize(); $query = $user->getconnection(); $validate = $user->getuserid(); //...page execution If $validate returns NULL, I kick a person out of the index page and return them to the login screen... The $user->getuserid(); method looks like: public function getuserid() { return $this->userid; } ...and is part of the initialize class.
  5. Why not just create a session variable that counts up as each question is answered correctly?  Or are you trying to run all your "sessions" through a database table for a particular reason? Something as simple as: [code=php:0] if($quest1 == "correct") $_SESSION['correct'] += 1; [/code] On each page...followed by [code=php:0] echo("You answered ".$_SESSION['correct']." of 10 questions correctly."; [/code] on the last page would make the most sense to me...
  6. I have a mass e-mailer for a private members-only website worked out and functioning perfectly...(I'll post some of the code below) ...the difficulty is that I want to be able to allow MULTIPLE attachments to the e-mail, not just one... ...when I simply add a 2nd file upload box and duplicate the multipart mime format with an additional boundary and file addition, it doesn't work.  I'll get the first file...but none of the others.  Help please? Current functioning code: [code=php:0] if($_GET['send'] == 1) {  $from = $user['email']; $subject = $_POST['subject']; $body = stripchars($_POST['body']);             $fileatt0 = $_FILES['file_attach0']['tmp_name']; $fileatt_type0 = $_FILES['file_attach0']['type']; $fileatt_name0 = $_FILES['file_attach0']['name']; $headers = 'From:'.$from." \r\n".'Reply-To:'.$from. " \r\n"; $headers .= 'Date:'.date("r")."\n"; $headers .= 'Subject: '.$subject."\n"; if (is_uploaded_file($fileatt0)) { $file0 = fopen($fileatt0,'rb'); $data0 = fread($file0,filesize($fileatt0)); fclose($file0); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n"."--{$mime_boundary}\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\n"."Content-Transfer-Encoding: 7bit\n\n".$body."\n\n"; $data0 = chunk_split(base64_encode($data0)); $message .= "--{$mime_boundary}\n"."Content-Type: {$fileatt_type0};\n"." name=\"{$fileatt_name0}\"\n"."Content-Disposition: attachment;\n"." filename=\"{$fileatt_name0}\"\n"."Content-Transfer-Encoding: base64\n\n".$data0."\n\n"."--{$mime_boundary}--\n"; $body = $message; } else { $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type:text/html; charset=\"iso-8859-1\" \r\n"';  } $sql = "SELECT id, email FROM user"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $id = $row['id']; if($_POST[$id] == 1) $email_list[] = $row['email'];             } if(isset($subject) && isset($body) && $subject != "" && $body != "") { for($x = 0; $x < count($email_list); $x++) { $headers .= "Message-ID: <".($x + 100). "@".$_SERVER['SERVER_NAME'].">". "\r\n"; $headers .= "To: ".$row['email']." \r\n"; mail($email_list[$x], $subject, $body, $headers); if($x == 0 && count($email_list) > 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x].", "); else if($x == 0 && count($email_list) == 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x]."</span>"); else if($x == (count($email_list) - 1) && $x != 0) echo($email_list[$x]."</span>"); else echo($email_list[$x].", "); } } ?> <form action="admin.php?tab=emailer&send=1" method="post" name="admin_emailer" enctype="multipart/form-data"> Subject:<br /><input name="subject" type="text" value="<?php echo($subject); ?>" class="longtext" maxlength="255"><br /><br /> Body:<br /><textarea name="body" cols="" rows=""><?php echo($body); ?></textarea><br /> Attachment:<input name="file_attach0" type=file><br /> <hr /> Send To:<br /> <input type="button" value="All Members" onClick="checkBox('Fat Cat');" />&nbsp;&nbsp;&nbsp; <input type="button" value="All Presenters" onClick="checkBox('Presenter');" />&nbsp;&nbsp;&nbsp; <input type="button" value="All Staff" onClick="checkBox('Staff/Admin');" />&nbsp;&nbsp;&nbsp; <input type="button" value="Everyone" onClick="checkBox('All');" /> <br /><br /> <table> <th>&nbsp;</th><th>&nbsp;Name&nbsp;</th><th>&nbsp;Group&nbsp;</th><th>&nbsp;</th><th>&nbsp;Name&nbsp;</th><th>&nbsp;Group&nbsp;</th>               //PHP Functions to Fill Table </table> <hr /> <p><input name="massmail_submit" type="submit" value="Send E-Mail"></p> </form> <?php [/code]
  7. IMO (which isn't always perfect) you're trying to insert a repeated "key"...or unique identifier...and the DB is rejecting it.  To avoid errors like this, I usually set up my SQL database with a generic "id" tag that auto-increments...and never try to hard-set it myself.  Also...you can run with an INSERT INTO .... ON DUPLICATE KEY UPDATE...  if you want to be able to update entries with an identical key that have shown up before...
  8. Any help available on this topic?  I'm very stuck...and it's a rather important function...most of the e-mails we send out have attachments.
  9. I've just finished updating the mass e-mailer for a members-only site with the ability to add attachments...and have followed a couple of tutorials to make sure I got it right... ...but apparently I've missed something...because the files that show up in my gmail box show as unknown files with an unkown file type and have a set "size" of 1k.  (The subject/message/sender/etc are all fine)  I'll post my code below...please help: Oh...another note...if I throw a die() in before the e-mail is sent out...the file IS recorded correctly in the $fileatt variables. [code=php:0]                                                   $from = $user['email']; $subject = $_POST['subject']; $body = stripchars($_POST['body']); $fileatt = $_FILES['file_attach']['tmp_name']; $fileatt_type = $_FILES['file_attach']['type']; $fileatt_name = $_FILES['file_attach']['name']; $headers = 'From:'.$from." \r\n".'Reply-To:'.$from. " \r\n"; $headers .= 'Date:'.date("r")."\n"; $headers .= 'Subject: '.$subject."\n"; if (is_uploaded_file($fileatt)) { $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n"."--{$mime_boundary}\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\n"."Content-Transfer-Encoding: 7bit\n\n".$message."\n\n"; $data = chunk_split(base64_encode($data)); $message .= "--{$mime_boundary}\n"."Content-Type: {$fileatt_type};\n"." name=\"{$fileatt_name}\"\n"."Content-Disposition: attachment;\n"." filename=\"{$fileatt_name}\"\n"."Content-Transfer-Encoding: base64\n\n".$data."\n\n"."--{$mime_boundary}--\n"; } else { $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type:text/html; charset=\"iso-8859-1\" \r\n"';  } $sql = "SELECT id, email FROM user"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $id = $row['id']; if($_POST[$id] == 1) $email_list[] = $row['email']; } if(isset($subject) && isset($body) && $subject != "" && $body != "") { for($x = 0; $x < count($email_list); $x++) { $headers .= "Message-ID: <".($x + 100). "@".$_SERVER['SERVER_NAME'].">". "\r\n"; $headers .= "To: ".$row['email']." \r\n"; mail($email_list[$x], $subject, $body, $headers); if($x == 0 && count($email_list) > 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x].", "); else if($x == 0 && count($email_list) == 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x]."</span>"); else if($x == (count($email_list) - 1) && $x != 0) echo($email_list[$x]."</span>"); else echo($email_list[$x].", "); } } [/code]
  10. Sure...here is the code: [code=php:0] $from = "admin@mydomain.com"; $subject = $_POST['subject']; $body = $_POST['body']; $headers  = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:'.$from."\r\n".'Reply-To:'.$from; $headers .= 'Date:'.date("r")."\r\n"; $headers .= 'Subject: '.$subject."\r\n"; //...code here to create array of emails to send mail to... if(isset($subject) && isset($body) && $subject != "" && $body != "") { for($x = 0; $x < count($email_list); $x++) { mail($email_list[$x], $subject, $body, $headers); if($x == 0 && count($email_list) > 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x].", "); else if($x == 0 && count($email_list) == 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x]."</span>"); else if($x == (count($email_list) - 1) && $x != 0) echo($email_list[$x]."</span>"); else echo($email_list[$x].", "); } } [/code]
  11. So I've got a great mail function that works just fine...which I only found out after going through my SMTP server logs and then sending mail to a completely unfiltered e-mail address... ...because it seems that 99% of mailbox providers (Gmail, Yahoo, Hotmail, etc) deny mail coming from my server... Obviously, that's a big problem.  No, I'm not creating a spam-mailer...more a "forgot password" response mailer... ...is there anything I can put in headers to pass through the filtering?  Or really...any sort of thing I can do to pass through the filtering?
  12. The server uses POP3/SMTP.  The SMTP Service is running with MailEnable.  Also...checking the logs...I'm finding: 11/01/06 11:34:28 SMTP-OU B2C0A0D352E04445A17E73E458DD3293.MAI 364 xx.xxx.xxx.xx RCPT RCPT TO:<junkmail@mydomain.com> 250 Accepted 34 14 UPDATE:  It looks like the mail is sending correctly, but is being blocked by the great majority of mailbox providers.  Obviously, that's not a good thing (especially since the emailer is primarily for allowing members to reset their password). ...so...maybe some ideas on how to get these e-mails unblocked?  Maybe something in the headers? 
  13. Yes...have checked the spam box and have tried sending to a variety of mail services (G-mail, Hotmail, Yahoo mail, private domain e-mails I own, etc).
  14. I've got a website running off a Win. 2003 Server with PHP 4.4.3 and MySQL 5 (though MySQL is unimportant to this problem).  Everything SEEMS to be working just fine...and in fact, when I send an e-mail through the contact form, I even get a report back that mail has been sent correctly... ...unfortunately...neither I, nor anyone else who tests the functionality, receives an e-mail from the contact form.  I can't find anything wrong with the code...maybe some help?  (code pasted below) [code=php:0] if(isset($subject) && isset($body) && $subject != "" && $body != "") {             for($x = 0; $x < count($email_list); $x++) { mail($email_list[$x], $subject, $body, $headers); if($x == 0 && count($email_list) > 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x].", "); else if($x == 0 && count($email_list) == 1) echo("<span class=\"notification\">E-Mail sent to: ".$email_list[$x]."</span>"); else if($x == (count($email_list) - 1) && $x != 0) echo($email_list[$x]."</span>"); else echo($email_list[$x].", "); } } [/code] Umm...I guess the other relevant part may be the $headers variable...which is: $headers  = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:'.$from."\r\n".'Reply-To:'.$from;
  15. Thank you. I actually am not using a Linux system. Our server is a Win2000 server...and the PHP script is pulling MSAccess databases from one server location to antoher and redistributing a main table through to other tables. In other words...I'm workin' with the worst I can get (Win2000 + MSAccess)! There are no error messages that come up...simply a failure to run. I'll look into the batch file more closely. Thank you for the link...though I think I've read over that page a couple of times with no luck for myself. I think I might need to read very slowly and take very careful notes this time. The chmod settings, however, are definitely correct :) I had that part figured.
  16. I've written a script in PHP to copy an MSAccess database file from one network location to another and then take that DB and copy rows from one table into several others...it's all just a bandaid for an ancient program that needs to be replaced... ...the problem, however, is getting this script to run off the desktop/command line. From what I've read about the PHP SAPI CLI/CGI I am able to just prepend my file with: #!/usr/bin/php However...it doesn't seem to be working... Any thoughts?
  17. The short of the problem: It doesn't seem (from an inexperienced eye) that there is any easy correlation between the way PHP records and reads time and the way MySQL records and reads time. My Difficulty: I want to record times at certain points in my PHP pages and store them in MySQL...in a format that can be read as a date/time and can be re-extracted and adjusted easily by PHP. Example: --On INSERT to the MySQL database, record the current date and time. --On query, display the previously recorded date and time in an easily readable format. --ON UPDATE to the MySQL database, take the previous time and add either x days or x weeks, etc. --On query...if a certain time has passed...spur another function. I know they're all essentially easy things to do...I'm just lost...
  18. Thanks for looking over this code with me so closely. The @ symbol is to surpress errors...as when the page initially loads, there should be no value in $_SESSION['perms'] and therefore $perms would throw an "undefined variable" error if it were not preceeded with @. I could do a if(isset($_SESSION['perms'])) $perms = $_SESSION['perms'];...but...yea...that's a lot more typing than just @. Of course...the short argument might be "why even bother to set a session variable to another variable"? Let's just say it results in less total typing in the end...and easier playing with code. ANYWAY...the page is simply refreshing to itself. The idea is that a person goes to this login page...puts in their username and password...clicks the "Login" button...and the page reloads...with the side menu now showing up. So...the answer is...the page loads to itself.
  19. [!--quoteo(post=355019:date=Mar 14 2006, 11:45 AM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 14 2006, 11:45 AM) [snapback]355019[/snapback][/div][div class=\'quotemain\'][!--quotec--] Nope.. it's not odd at all.. If you're going to be working with sessions (server side cookies) then you need to initialize them before you can write and read from them.. it only makes sense, doesn't it? [/quote] Makes sense...just figured that a session_start() was to initialize a session...i.e...start it...not to propogate the same session across pages. I appreciate the help there...but apparently that was not the problem...still no propogation across pages.
  20. [!--quoteo(post=354991:date=Mar 14 2006, 10:42 AM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 14 2006, 10:42 AM) [snapback]354991[/snapback][/div][div class=\'quotemain\'][!--quotec--] Where's your [code]session_start()[/code]???? it should be the top most code.. before any includes, before anything! [/quote] Well...my session_start() doesn't come until after the user presses the "Login" button. Once that is done, the page refreshes and a session_start() is called...then session variables declared. I was under the impression that a session_start() did not need to be started until you wanted one...and then variables declared... ...do I need a session_start() at the beginning of every page from which I want session variables? That seems a bit odd...
  21. My problem is (hopefully) not in the implementation of a session...using PHP 5...but my session does not seem to propogate itself across pages...or even on refresh to the same page...help? Login page takes a username and password...checks against MySQL database...and then reloads...grabbing the session variable $_SESSION['perms'] to build a menu. When echoing this $SESSION['perms'], it comes up empty...? [code] <?php //----------LOGIN------------------------------------------------------------------------------------------------------------------------------- //User Login ...and other commented info //---------------------------------------------------------------------------------------------------------------------------------------------- //Includes--------------------------------------------------------------------------------------------------------------------------------------     require("MySQLQueries.php");  //holds my MySQL functions...works fine.     require("FormsandHeaders.php");  //holds generic html output...works fine. //Declaration of Variables----------------------------------------------------------------------------------------------------------------------     $perms = @$_SESSION['perms'];  //<--MY PROBLEM CHILD!!!          $email = @$_POST['emailbox'];     $pass = @$_POST['passwordbox'];     $login = @$_POST['Login'];     $pagename = "Login.php";     $pagetitle = "(company) Login";      //Functions-------------------------------------------------------------------------------------------------------------------------------------     if($login) //if the login button was pressed     {         $getuser = array();         $getuser = fetchSingle("user", "$email", "email"); //get the username         $checkpass = @$getuser['password'];         if($checkpass == $pass) //ensure the password, login success         {             session_start();  //start the session             $fullname = $getuser['firstname']." ".$getuser['lastname'];             $sessperms = $getuser['catid'];             $form1 = "Login Successful.  Welcome ".$fullname.".";             $_SESSION['user']=$fullname;  //set session variable             $_SESSION['perms']=$sessperms; //set session variable         }         else  //show login failed         {             $times = 0;             $form1 = "Login Failed.  After ".$times." more failed attempts, your computer will be locked out";             $form1 .=" of the system for 24 hours.<br>";             $form1 .="<a href=\"Login.php\">Try Again</a>";         }     }     else  //create the login form     {         $form1 = "<br><br><table align=\"center\"><tr><td colspan=\"2\">Login to (company)</td>";         $form1 .="</tr><form action=\"Login.php\" method=\"POST\" name=\"LoginForm\"><tr>";         $form1 .="<td>E-mail:</td><td><input name=\"emailbox\" type=\"text\" id=\"emailbox\" maxlength=\"30\"></td></tr>";         $form1 .="<tr><td>Password:</td><td><input name=\"passwordbox\" type=\"password\" id=\"passwordbox\" maxlength=\"30\"></td></tr>";         $form1 .="<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"Login\" value=\"Login\"></td></tr></form></table>";     }          $header = getHeader($pagetitle);  //get page template          if($perms) $menu = getMenu($perms, $pagename);  //get menu options     else $menu = getMenu(NULL, $pagename);      //Page Execution--------------------------------------------------------------------------------------------------------------------------------     echo($header);  //execute the page.     echo("<table align=\"center\" width=\"780\"><tr><td>");     echo($menu);     echo("</td><td align=\"left\">");     echo($form1);     echo("</td></tr></table>"); ?> [/code]
  22. Changing by session id, simply save the preferred CSS style into the database with the user (I'm assuming there is a user database...). Once the user logs in, the header href can point to the correct stylesheet by a php variable in the link path. Changing by row...like if you want alternating row colors or whatever...simply determine if the current row is dividable by two...and if so, run one style...if not, run the other. No separate stylesheet is needed, simply only two style classes.
  23. Personally, I prefer sessions. They're easier/cleaner. That's just me though.
  24. Sounds like a simple HTML formatting issue... [code] <table>      <tr>           <td>data1</td>           <td>data2</td>      <tr> <!--Repeat for as many rows as you like with those two columns--> </table> [/code] Since getting data from the database doesn't seem to be an issue for you, I'll leave that part to you.
  25. Yes...you need a loop within a loop... ...you will need to acquire all records from 1 customer with unique SKUs... ...then...loop an output of each SKU ...then...move on to the next customer.
×
×
  • 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.