Jump to content

Shamrox

Members
  • Posts

    92
  • Joined

  • Last visited

    Never

Everything posted by Shamrox

  1. I have a simple form that submits into two tables. the first table would generate an id that would then be submitted into the second table along with some other info. It seemed to be working, but i have several users that can never seem to get anything to save to the main table. I look in the database and the main table will not have an entry, but the secondary table will have an entry, but the ID field will be blank. Here is the sql, could you please tell me what might be wrong?? [code] if (isset($_POST['name'])) { $name = $_POST['name'];   $ok1 = @mysql_query("INSERT INTO spec_supplier SET   name='$name',   ctype='$ctype',   caption='$caption',   online='$online',   sidebar_title='$sidebar_title',   sidebar_content='$sidebar_content' "); $ok2 =  @mysql_query("INSERT INTO spec_categories SET sid=(last_insert_id()), catname='$name' ");   if ($ok1 and $ok2) { echo ' <p>Supplier added successfully.';   } else {   echo '<p>Error adding submitted supplier: ' .   mysql_error() . '</p>'; } } [/code]
  2. Ok, odd thing just happened. I echo'd what you said, I used myself as test email address, it echo'd my address once along with the course name, etc. That seemed fine. I received one email (first time I haven't gotten two or more), but when i looked at the To: line inside the email, my address was listed twice.
  3. When I test it, I only use one address, so that's not it, but i'll look into cleaning up the code. would the switch function be more efficient or just look cleaner?
  4. Can anyone tell me why my code sends two identical emails to the recipient and what I'd need to change to only send one? [code] <?PHP if(@$_REQUEST['form'] == "" || @$_REQUEST['registrarid'] == ""){ echo "<p>This page cannot be called directly.</p>"; exit(); } if(@$_REQUEST['step'] != "two"){ ob_start(); if($_REQUEST['form'] == "agreement"){ include("trainingagreement.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email'];                  }elseif($_REQUEST['form'] == "pdfagreement"){ include("trainingagreement.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "confirmation"){ include("trainingconfirm.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "pdfconfirmation"){ include("trainingconfirm.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "rescheduledconfirmation"){ include("rescheduledconfirm.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "pdfrescheduledconfirmation"){ include("rescheduledconfirm.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "reminderconfirmation"){ include("reminderconfirm.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "pdfreminderconfirmation"){ include("reminderconfirm.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "confirmation2"){ include("trainingconfirm2.php"); $to = $client_contact['email'].", ".$student_contact['email'].", ".$stbrep['stb_email']; }elseif($_REQUEST['form'] == "po"){ include("purchaseorder.php"); $to = $vendor['vendoremail']; }elseif($_REQUEST['form'] == "survey"){ include("studentsurvey.php"); $to = $student_contact['email']; }elseif($_REQUEST['form'] == "invoice"){ include("invoice.php"); $to = $row_Recordset1['billemail']; //change this } ob_end_clean(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"    "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Send <?PHP echo $_REQUEST['form']; ?></title> </head> <body> <form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="registrarid" value="<?PHP echo $_REQUEST['registrarid']; ?>"> <input type="hidden" name="form" value="<?PHP echo $_REQUEST['form']; ?>"> <input type="hidden" name="step" value="two"> <p> Send <?PHP echo $_REQUEST['form']; ?> to: <input type="text" name="send_to" value="<?PHP echo $to; ?>" size="50"> (Example: email@yourdomain.com, email2@yourdomain.com)<br> <input type="submit" name="submit_button" value="Send <?PHP echo $_REQUEST['form']; ?>"> </p> </form> </body> </html> <?PHP exit(); }elseif(@$_REQUEST['step'] == "two"){ ob_start(); if($_REQUEST['form'] == "agreement"){ include("trainingagreement.php");     }elseif($_REQUEST['form'] == "pdfagreement"){ include("trainingagreement.php"); }elseif($_REQUEST['form'] == "confirmation"){ include("trainingconfirm.php"); }elseif($_REQUEST['form'] == "pdfconfirmation"){ include("trainingconfirm.php"); }elseif($_REQUEST['form'] == "rescheduledconfirmation"){ include("rescheduledconfirm.php"); }elseif($_REQUEST['form'] == "pdfrescheduledconfirmation"){ include("rescheduledconfirm.php"); }elseif($_REQUEST['form'] == "reminderconfirmation"){ include("reminderconfirm.php"); }elseif($_REQUEST['form'] == "pdfreminderconfirmation"){ include("reminderconfirm.php"); }elseif($_REQUEST['form'] == "confirmation2"){ include("trainingconfirm2.php"); }elseif($_REQUEST['form'] == "po"){ include("purchaseorder.php"); }elseif($_REQUEST['form'] == "survey"){ include("studentsurvey.php"); }elseif($_REQUEST['form'] == "invoice"){ include("invoice.php"); } $message=ob_get_contents(); ob_end_clean(); $success = "Email sent successfully!"; $failure = "Failed to send email!!!"; if($_REQUEST['form'] == "agreement"){ $success = "Agreement sent successfully."; $failure = "Failed to send agreement email!!"; $from = "registrar@domain.com"; $subject = "Training Agreement - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; }elseif($_REQUEST['form'] == "confirmation"){ $success = "Confirmation sent successfully."; $failure = "Failed to send confirmation email!!"; $from = "registrar@domain.com"; $subject = "Confirmation - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; }elseif($_REQUEST['form'] == "rescheduledconfirmation"){ $success = "Rescheduled Confirmation sent successfully."; $failure = "Failed to send rescheduled confirmation email!!"; $from = "registrar@domain.com"; $subject = "Rescheduled Confirmation - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; }elseif($_REQUEST['form'] == "reminderconfirmation"){ $success = "Reminder Confirmation sent successfully."; $failure = "Failed to send reminder confirmation email!!"; $from = "registrar@domain.com"; $subject = "Reminder Confirmation - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; }elseif($_REQUEST['form'] == "confirmation2"){ $success = "Confirmation sent successfully."; $failure = "Failed to send confirmation email!!"; $from = "registrar@domain.com"; $subject = "Confirmation - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; }elseif($_REQUEST['form'] == "po"){ $success = "Purchase order sent successfully."; $failure = "Failed to send purchase order email!!"; $from = $stbrep['stb_email']; $subject = "Purchase Order - " . $student_contact['lastname'] . " - " . $vendor['Company_Name'] . ""; }elseif($_REQUEST['form'] == "survey"){ $success = "Survey sent successfully."; $failure = "Failed to send survey email!!"; $from = $stbrep['stb_email']; $subject = "Survey - " . $student_contact['lastname'] . " - " . $vendor['Company_Name'] . ""; }elseif($_REQUEST['form'] == "invoice"){ $success = "Invoice sent successfully."; $failure = "Failed to send invoice email!!"; $from = $row_Recordset1['stb_email']; $subject = "Invoice - " . $row_Recordset1['invoicenumber'] . " - " . $row_Recordset1['studentlast'] . " - " . $row_Recordset1['coursecode'] . " - " . $row_Recordset1['coursename'] . ""; } if ($_REQUEST['form'] == 'pdfconfirmation') { $from = "registrar@domain.com"; $subject = "Confirmation - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; $message = 'Attached you will find your confirmation and other pertinent details to your upcoming training event.  If you have any questions regarding your enrollment, please call us toll free at 1.888.555.5555.<br /><br /> Thank you,<br /><br /> Education Services<br /> Company Name'; $success = "PDF confirmation sent successfully."; include 'createpdf.php'; $results = true; } elseif ($_REQUEST['form'] == 'pdfrescheduledconfirmation') { $from = "registrar@domain.com"; $subject = "Reschedule Confirmation - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; $message = 'Attached you will find your reschedule confirmation and other pertinent details to your upcoming training event.  If you have any questions regarding your enrollment, please call us toll free at 1.888.555.5555.<br /><br /> Thank you,<br /><br /> Education Services<br /> Company Name'; $success = "PDF Reschedule confirmation sent successfully."; include 'createpdfreschedule.php'; $results = true; } elseif($_REQUEST['form'] == "pdfagreement"){                                 $success = "PDF Agreement sent successfully."; $failure = "Failed to send agreement email!!"; $from = "registrar@domain.com"; $subject = "Training Agreement - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . "";                                 $message = 'Attached you will find your agreement and other pertinent details to your upcoming training event.  If you have any questions regarding your enrollment, please call us toll free at 1.888.555.5555.<br /><br /> Thank you,<br /><br /> Education Services<br /> Company Name'; include 'createpdfagreement.php'; $results = true; } elseif ($_REQUEST['form'] == 'pdfreminderconfirmation') { $from = "registrar@domain.com"; $subject = "Confirmation - " . $student_contact['lastname'] . " - " . $course['course_num'] . " - " . $course['ctitle'] . ""; $message = 'Attached you will find your reminder confirmation and other pertinent details to your upcoming training event.  If you have any questions regarding your enrollment, please call us toll free at 1.888.555.5555.<br /><br /> Thank you,<br /><br /> Education Services<br /> Company Name'; $success = "PDF Reminder confirmation sent successfully."; include 'createpdfreminder.php'; $results = true; } else { $send_to = $_POST['send_to']; $message = str_replace("../invoice.css", "http://www.domain.com/invoice.css", $message); $message = preg_replace("/\.?\.?\/images\/logo_hi-res_sm.gif/", "http://www.domain.com/images/logo_hi-res_sm.gif", $message); //$message = str_replace("/images/logo_hi-res_sm.gif", "http://www.domain.com/images/logo_hi-res_sm.gif", $message); $message = str_replace("/images/gray_dot.gif", "http://www.domain.com/images/gray_dot.gif", $message); $message = str_replace("/images/shared_dot_clear.gif", "http://www.domain.com/images/shared_dot_clear.gif", $message); $sep = "\n"; $boundary = md5(uniqid("",true)); $b1 = "b1---$boundary"; $headers  = "From: $from$sep"; $headers .= "To: $send_to$sep"; $headers .= "Return-Path: $from$sep"; $headers .= "MIME-Version: 1.0$sep"; $headers .= "Content-Type: multipart/alternative; boundary=\"$b1\"$sep"; $headers .= "$sep";  //now set up the message $messageHeader = "--$b1$sep"; //default message $defaultmessage = "Go get yourself an html mail client"; $messageHeader .= $defaultmessage.$sep; $messageHeader .= "$sep";  //html message $messageHeader .= "--$b1$sep"; $messageHeader .= 'Content-Type: text/html; charset="iso-8859-1"'.$sep; $messageHeader .= "Content-Transfer-Encoding: 8bit$sep"; $messageHeader .= "$sep"; $messageHeader .= $message; $messageHeader .= "$sep"; $messageHeader .= "--$b1--"; $messageHeader .= "$sep"; $results = @mail($send_to, $subject, $messageHeader, $headers); } if($results){ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"    "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Message Sent</title> </head> <body> <p><a href="dashboard-new.php">Dashboard</a> | <a href="registrar_new.php?registrarid=<?PHP echo $_REQUEST['registrarid']; ?>">Registrar</a></p> <p><?PHP echo $success; ?></p> <p>Message sent to: <?PHP echo $send_to; ?></p> <p>The following message was sent:</p> <hr> <?PHP echo $message; ?> </body> </html> <?PHP }else{ echo $failure; } exit(); } ?> <p>This page cannot be called directly.</p> [/code]
  5. I don't like the sprintf much either, but I generate a lot of code quickly in Dreamweaver and it forces it upon you. When i try to hand code things, it gets a bit garbled in there. Anyway, i'll give your code a whirl and see how it pans out. Thanks for your time.
  6. I completely understand what the above code is achieving, but I'm having the worst time integrating it into my present code. I can't seem to get the syntax correct. How would I put the above into this and make it work? [code] $colname_rs_test = "0"; if (isset($_GET['rep'])) {   $colname_rs_test = (get_magic_quotes_gpc()) ? $_GET['rep'] : addslashes($_GET['rep']); } mysql_select_db($database_spectrum, $spectrum); $query_rs_test = sprintf("SELECT `spec_course`.`ctitle`, `spec_client`.`name`, `spec_contacts`.`lastname`, DATE_FORMAT(`spec_registrar`.`orderdate`, '%%c/%%e/%%Y') AS `orderdate1`, DATE_FORMAT(`spec_registrar`.`startdate`, '%%c/%%e/%%Y') AS `startdate1`,`spec_registrar`.* FROM `spec_registrar`  INNER JOIN `spec_students` ON `spec_registrar`.`studentid` = `spec_students`.`studentid` INNER JOIN `spec_client` ON `spec_client`.`clientid` = `spec_students`.`clientid` INNER JOIN `spec_contacts` ON `spec_contacts`.`contactid` = `spec_students`.`contactid` INNER JOIN `spec_course` ON `spec_course`.`course_num` = `spec_registrar`.`coursecode` WHERE `spec_registrar`.`invoiced_status` <> 'on' AND `spec_registrar`.`stbrepid`=%s ORDER BY `spec_registrar`.`registrarid` DESC ", GetSQLValueString($colname_rs_test, "int")); $query_limit_rs_test = sprintf("%s LIMIT %d, %d", $query_rs_test, $startRow_rs_test, $maxRows_rs_test); $rs_test = mysql_query($query_limit_rs_test, $spectrum) or die(mysql_error()); $row_rs_test = mysql_fetch_assoc($rs_test); [/code] Your $whereClause would replace the second part of my WHERE. Just can't seem to integrate. Thanks
  7. I'd like to dynamically display data from my table and have links across the top that the user could easily click to alter the query. For instance, the list would be all of the sales reps names. If you click one name, the query would be filtered to show just that reps data. Ok, that's the easy part that I have working, but I don't know what to put in the URL string for ALL records to show. here's what I do now. domainname.com/page.php?repid=1 the repid would change based on the link clicked and filters the data. What would be used for ALL records to show? A wildcard of some sort? Thanks.
  8. Like this? "'" . mysql_real_escape_string($_POST['registrationstatus']) . "',".
  9. Ok, here is the code used for the submit of the record. I hope this gives a clue to what's going on. [code] if(isset($_POST['submit_create_record'])){ $varorderdate = preg_split("/(-|\/)/",$_POST['orderdate']); $varorderdate = $varorderdate[2]."-".$varorderdate[0]."-".$varorderdate[1]; $varinvoicedate = preg_split("/(-|\/)/",$_POST['invoicedate']); $varinvoicedate = $varinvoicedate[2]."-".$varinvoicedate[0]."-".$varinvoicedate[1]; $varstartdate = preg_split("/(-|\/)/",$_POST['startdate']); $varstartdate = $varstartdate[2]."-".$varstartdate[0]."-".$varstartdate[1]; $varenddate = preg_split("/(-|\/)/",$_POST['enddate']); $varenddate = $varenddate[2]."-".$varenddate[0]."-".$varenddate[1]; $sql = "SELECT `invoicenumber` FROM `spec_invoice` WHERE `invoicenumber` REGEXP '^" . date('Y') . "[0-9]*$' ORDER BY LENGTH(`invoicenumber`) DESC, `invoicenumber` DESC LIMIT 1;"; $results = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($results) > 0){ $row = mysql_fetch_assoc($results); $invoicenumber_invoice = substr($row['invoicenumber'], 4); $invoicenumber_invoice = date('Y').($invoicenumber_invoice+1); }else{ $invoicenumber_invoice = date('Y')."1"; } $sql = "SELECT `invoice` FROM `spec_registrar` WHERE `invoice` REGEXP '^" . date('Y') . "[0-9]*$' ORDER BY LENGTH(`invoice`) DESC, `invoice` DESC LIMIT 1;;"; $results = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($results) > 0){ $row = mysql_fetch_assoc($results); $invoicenumber_registrar = substr($row['invoice'], 4); $invoicenumber_registrar = date('Y').($invoicenumber_registrar+1); }else{ $invoicenumber_registrar = date('Y')."1"; } if($invoicenumber_registrar > $invoicenumber_invoice){ $invoicenumber = $invoicenumber_registrar; }else{ $invoicenumber = $invoicenumber_invoice; } $vendor_stb_po_number = "V".$invoicenumber; $sql = "INSERT INTO `spec_registrar` ( `registrarid` , `studentid` , `scheduelid` , `clientid` , `clientcontactid` , `stbrepid` , `invoice` , `training_agreement_sent` , `agreement_received` , `order_placed_vendor` , `confirmation_received_vendor` , `confirmation_sent_student` , `invoiced_status` , `old_studentid` , `old_courseid` , `old_scheduleid` , `old_vendorid` , `orderdate` , `invoicedate` , `quantity` , `discount` , `sale_price` , `stb_discount` , `salesterms` , `vendorpromocode`, `stbpromocode`, `vendorlistprice` , `vendororder` , `confirmationnumber` , `paymentmethod` , `cogs` , `comment` , `coursecode` , `vendorname` , `VendorStbPoNumber` , `VendorStbPoDescription` , `VendorStbPoTerms` , `courselength` , `startdate` , `enddate` , `starttime` , `endtime` , `timenotes` , `vendorid` , `billingcompanyname` , `billname` , `billemail` , `billaddress1` , `billaddress2` , `billcity` , `billstate` , `billclientid` , `billcontactid` , `billzip` , `purchase_order` , `contract_number` , `payment_method` , `cc_number` , `approvalcode` , `cc_notes` , `cost_center` , `status` , `lastupdate` ) VALUES(". "'',". //registrarid "'" . $_POST['selectstudent'] . "',". //studentid "'',". //scheduleid "'" . $_POST['selectclient'] . "',". //clientid "'" . $_POST['selectclient_contact'] . "',". //clientcontactid "'" . $_POST['stbrepid'] . "',". "'" . $invoicenumber . "',". //invoice "'" . @$_POST['training_agreement_sent'] . "',". "'" . @$_POST['agreement_received'] . "',". "'" . @$_POST['order_placed_vendor'] . "',". "'" . @$_POST['confirmation_received_vendor'] . "',". "'" . @$_POST['confirmation_sent_student'] . "',". "'" . @$_POST['invoiced_status'] . "',". "'',". //old_studentid "'',". //old_courseid "'',". // old_scheduleid "'',". //old_vendorid "'" . $varorderdate . "',". //orderdate "'" . $varinvoicedate . "',". //invoicedate "'" . $_POST['quantity'] . "',". //quantity "'" . $_POST['discount'] . "',". //discount "'" . $_POST['sale_price'] . "',". //sale_price "'" . $_POST['stb_discount'] . "',". //stb_discount "'" . $_POST['salesterms'] . "',". //salesterms "'" . $_POST['vendorpromocode'] . "',". //vendor promo code "'" . $_POST['stbpromocode'] . "',". //stb promo code "'" . $_POST['vendorlistprice'] . "',". //vendorlistprice "'',". //vendororder "'" . $_POST['confirmationnumber'] . "',". //confirmationnumber //"'" . $_POST['cancellationby'] . "',". //cancelby //"'" . $_POST['cancellationcomments'] . "',". //cancelcomment //"'" . $_POST['cancellationdate'] . "',". //canceldate "'" . $_POST['paymentmethod'] . "',". //paymentmethod "'" . $_POST['cogs'] . "',". //cogs "'" . $_POST['comments'] . "',". //comment "'" . $_POST['coursecode'] . "',". //coursecode "'" . $_POST['vendor'] . "',". //vendorname "'" . $vendor_stb_po_number . "',". //VendorStbPoNumber "'" . $_POST['stb_po_description'] . "',". //VendorStbPoDescription "'" . $_POST['stb_po_terms'] . "',". //VendorStbPoTerms "'" . $_POST['courselength'] . "',". //courselength "'" . $varstartdate . "',". //startdate "'" . $varenddate . "',". //enddate "'" . $_POST['starttime'] . "',". //starttime "'" . $_POST['endtime'] . "',". //endtime "'" . $_POST['timenotes'] . "',". //timenotes "'" . $_POST['vendor_id'] . "',". //vendorid "'" . $_POST['billingcompanyname'] . "',". //billingcompanyname "'" . $_POST['billingname'] . "',". //billname "'" . $_POST['billingemail'] . "',". //billemail "'" . $_POST['billingaddress1'] . "',". //billaddress1 "'" . $_POST['billingaddress2'] . "',". //billaddress2 "'" . $_POST['billingcity'] . "',". //billcity "'" . $_POST['billingstate'] . "',". //billstate "'',". //billclientid "'',". //billcontactid "'" . $_POST['billingzip'] . "',". //billzip "'" . $_POST['purchase_order'] . "',". //purchase_order "'',". //contract_number "'" . $_POST['paymentmethod'] . "',". //payment_method "'" . $_POST['cc_number'] . "',". //cc_number "'" . $_POST['approvalcode'] . "',". //approval code "'" . $_POST['cc_notes'] . "',". //cc_notes "'" . $_POST['cost_center'] . "',". //cost_center "'" . $_POST['registrationstatus'] . "',". //status "'');"; //lastupdate $results = mysql_query($sql) or die(mysql_error()); if($results){ $message = "Registrar Created."; $registrarid = mysql_insert_id(); }else{ $message = "Error Creating Registrar!"; } [/code]
  10. line 2 has nothing to do with that. Line to is my include for the database connection. It seems that all my other issues came from moving from php4 to 5. I had to turn register_globals ON at the server to fix one issue. Would this have anything to do with magic quotes?
  11. Hmmm, i get this error displayed in my browser when I submit. 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 's Training Company','Dirk Digler','email@domain.com','400 7th St','Roo' at line 2
  12. Ok, that partially fixed things. Thanks! Now I'm getting a PHP notice error of: PHP Notice:  Undefined offset:  1 in /var/www/vhosts/domain.com/httpdocs/folder/file.php on line 76 that points to this code. Anything wrong here? if(isset($_POST['submit_create_record'])){ $varorderdate = preg_split("/(-|\/)/",$_POST['orderdate']); $varorderdate = $varorderdate[2]."-".$varorderdate[0]."-".$varorderdate[1]; $varinvoicedate = preg_split("/(-|\/)/",$_POST['invoicedate']); $varinvoicedate = $varinvoicedate[2]."-".$varinvoicedate[0]."-".$varinvoicedate[1]; $varstartdate = preg_split("/(-|\/)/",$_POST['startdate']); $varstartdate = $varstartdate[2]."-".$varstartdate[0]."-".$varstartdate[1]; $varenddate = preg_split("/(-|\/)/",$_POST['enddate']); $varenddate = $varenddate[2]."-".$varenddate[0]."-".$varenddate[1];
  13. I just moved a client from a shared server host to a dedicated server, and in the process the PHP version went from 4 to 5. Most of the pages work, no errors appear but certain values are not passed to links that would show records. In another situation, i have a page that lists all the vendors. It does this correctly, but when you click a link to go to a specific vendor's detail page, the same record loads no matter which vendor you click.  Are there some changes in PHP 5 that would affect this?  I can try to post some examples of the code if that would help, but it's pretty extensive. Thanks for any and all help. 
  14. When i run it on a server with mysql version 4.0.25 it runs fine. When I run it on a server with mysql version 4.1.8 I get the following 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 ') GROUP BY lastname' at line 1 Oh, and the above error shows up as the only data that is in the excel spreadsheet that I have it output to.
  15. Based on my code below, can anyone tell me why this outputs data fine in one version of Mysql, but gives me a bad syntax error in another? <?php mysql_select_db($database_moms, $moms); $query_rs_usernamematch = "SELECT moms_users.eid FROM moms_users WHERE moms_users.username "; $rs_usernamematch = mysql_query($query_rs_usernamematch, $moms) or die(mysql_error()); $row_rs_usernamematch = mysql_fetch_assoc($rs_usernamematch); $totalRows_rs_usernamematch = mysql_num_rows($rs_usernamematch); mysql_select_db($database_moms, $moms); $query_rs_username = "SELECT * FROM moms_users WHERE moms_users.username ='".$_SESSION['MM_Username']."'"; $rs_username = mysql_query($query_rs_username, $moms) or die(mysql_error()); $row_rs_username = mysql_fetch_assoc($rs_username); $totalRows_rs_username = mysql_num_rows($rs_username); mysql_select_db($database_moms, $moms); $query_rs_pubid2 = "SELECT * FROM moms_pubtable ORDER BY listtitle ASC"; $rs_pubid2 = mysql_query($query_rs_pubid2, $moms) or die(mysql_error()); $row_rs_pubid2 = mysql_fetch_assoc($rs_pubid2); $totalRows_rs_pubid2 = mysql_num_rows($rs_pubid2); ?> <?php mysql_select_db($database_moms, $moms); $query_rs_pubid = "SELECT pubid, listtitle FROM moms_pubtable ORDER BY pubid ASC"; $rs_pubid = mysql_query($query_rs_pubid, $moms) or die(mysql_error()); $row_rs_pubid = mysql_fetch_assoc($rs_pubid); $totalRows_rs_pubid = mysql_num_rows($rs_pubid); ?> <? if(isset($_POST['ok'])) // submit button pressed { $_POST['display'] = trim($_POST['display']); if($_POST['display'] == '') { die("nothing chosen."); } else { header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=maillist.xls"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Expires: 0"); $select = "SELECT DISTINCT firstname, lastname, street1, street2, city, state, zipcode, zip4, country, countrycode, MAX(quantity) FROM moms_customer, moms_lists WHERE moms_customer.custnumber = moms_lists.custnumber AND pubid IN($display) GROUP BY lastname"; $export = mysql_query($select, $moms) or die(mysql_error()); $row = mysql_fetch_assoc($export); $totalRows = mysql_num_rows($export); $fields = mysql_num_fields($export); // BEGIN FOR LOOPING for ($i = 0; $i < $fields; $i++) { $header .= mysql_field_name($export, $i) . "\t"; } while($row = mysql_fetch_row($export)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); echo $header."\n".$data; //IF STATMENT THAT IS PRODUCED IF NO DATA IS PRESENT if ($data == "") { $data = "n(0) Records Found!n"; } die($sql); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <link href="moms.css" rel="stylesheet" type="text/css"> <script> function addToField(selbox) { selectedIndex = selbox.options.selectedIndex; selectedValue = selbox.options[selectedIndex].value; if(selectedValue == "") return; if(document.myForm.display.value != "") document.myForm.display.value += ","; document.myForm.display.value += selectedValue; } </script> </head> <body> <p><?php adminToolbar(); ?></p> <table width="800" height="233" border="1" align="center" cellpadding="5" cellspacing="0"> <td align="center"> <form name="myForm" method="POST" action="<?=$_SERVER['PHP_SELF'] ?>"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Select a Pub ID:</td> <td>Select a Pub Title: </td> <td> </td> <td> </td> </tr> <tr> <td><select size="1" name="select1" onChange="addToField(this);"> <option value="">Choose:</option> <?php do { ?> <option value="<?php echo $row_rs_pubid['pubid']?>"><?php echo $row_rs_pubid['pubid']?> <?php echo $row_rs_pubid['listtitle']?></option> <?php } while ($row_rs_pubid = mysql_fetch_assoc($rs_pubid)); $rows = mysql_num_rows($rs_pubid); if($rows > 0) { mysql_data_seek($rs_pubid, 0); $row_rs_pubid = mysql_fetch_assoc($rs_pubid); } ?> </select></td> <td><select size="1" name="select2" onChange="addToField(this);"> <option value="">Choose:</option> <?php do { ?> <option value="<?php echo $row_rs_pubid2['pubid']?>"><?php echo $row_rs_pubid2['listtitle']?></option> <?php } while ($row_rs_pubid2 = mysql_fetch_assoc($rs_pubid2)); $rows = mysql_num_rows($rs_pubid2); if($rows > 0) { mysql_data_seek($rs_pubid2, 0); $row_rs_pubid2 = mysql_fetch_assoc($rs_pubid2); } ?> </select></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td colspan="2">List of Pub ID's: <input name="display" type="text" size="30"> <input type="submit" name="ok" value="Run Mailing List"> <input type="reset" name="Reset" value="Reset"></td> <td> </td> <td> </td> </tr> </table> <br /> <br /> </form> <p> </p></td> </table> <p> </p> <p><?php echo $row_rs_username['name']; ?></p> <p> </p> <p> </p> <p> </p> <p> </p> </body> </html> <?php mysql_free_result($rs_pubid); mysql_free_result($rs_pubid2); ?> Here is the specific code that creates the output query $select = "SELECT DISTINCT firstname, lastname, street1, street2, city, state, zipcode, zip4, country, countrycode, MAX(quantity) FROM moms_customer, moms_lists WHERE moms_customer.custnumber = moms_lists.custnumber AND pubid IN($display) GROUP BY lastname";
×
×
  • 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.