Jump to content

jperez260

Members
  • Posts

    15
  • Joined

  • Last visited

jperez260's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry... Nothing Crashes Seems like the "or die" is stopping the INSERT I don't get any detail of the error, maybe since I don't have a way to print the error. The error I get is what I have in the "or die" container as text. I've used tsql from the command line and I can get it to INSERT to the mssql server but from my php script no deal. is there way you can recommend to print out errors so i can dig deeper?
  2. Try using the "header" in your php code instead of redirect header(Location: '$_SERVER["PHP_SELF"]?interface=login');
  3. Hello All, I'm trying to use PHP to post to MSSQL server, I can get a connection however when I attempt my MSSQL Statement the query just won't work. This is most troubling, anyone have any suggestions Here's my code $conn = mssql_connect( 'myServer', "username", 'password', 'database' ) or die('Error Connecting'); $sql = "INSERT INTO Employees (Area, isTicketRep) VALUES ('789456', '1')"; mssql_query($conn, $sql) or die('Error Querying MSSQL Database'); mssql_close($conn); I have tried an if statement to ensure a connection, I have a connection....however the query just wont execute. There are numerous column on my database table but I'm only submitted selected field. In addition the actual table is called "Employees" but on the server reads "dbo.Employees". My Database is called "cs_all" Just won't seem to query, thanks in advance for any suggestions
  4. UPDATE!!! Ok I'm a dope This seems to work... $search_sql = " SELECT * FROM tracking INNER JOIN sender ON tracking_sender_id = sender_id INNER JOIN method ON tracking_method_id = method_id WHERE (tracking_recepient LIKE '%" . $_POST['search'] . "%') ORDER BY tracking_date DESC"; Sorry for crying wolf :-/ I added the parentheses as a last effort before I came to the php community however I did not attempt to add the ORDER BY after the parentheses , didn't seem to work before but now it does. :-|
  5. I do not have it in here due to it throwing an error.... I'm not sure where is the best place to put it... I've tried the following... DOES NOT WORK - ERROR $search_sql = " SELECT * FROM tracking INNER JOIN sender ON tracking_sender_id = sender_id INNER JOIN method ON tracking_method_id = method_id ORDER BY tracking_date ASC WHERE (tracking_recepient LIKE '%" . $_POST['search'] . "%')";
  6. Hello All, I've added search to my CMS and one column of data in particular is a date column. My whileLoop spits out data I want however it sorts the date field ASC but I need is DESC. I've tried adding the ORDER BY in several different ways however I keep getting an error... what would be the best approach to get it to sort the way I want using my current SELECT statement $search_sql = " SELECT * FROM tracking INNER JOIN sender ON tracking_sender_id = sender_id INNER JOIN method ON tracking_method_id = method_id WHERE (tracking_recepient LIKE '%" . $_POST['search'] . "%')"; the above code works fine but the output sorts ASC, can seem to add the ORDER BY in an appropriate manner to get it DESC. Any advice ? Thank you in advance
  7. where is your closing curly brace?
  8. Hello All, I have a form that has a DropDown list that is called from an SQL statement; in the SQL table it has a "name" and "email", what I want is the form to grab the "email" as a variable from a "onChange" event so when my form is posted it carries the "email" as a variable that I can use in a function. I can add the email as a hidden <input> however since I don't know how to create an onChange event to grab the "email" from the SQL instance when the drop down is selected I can't pass the email as a variable when the form is posted. I suppose this either needs to be done in Ajax or using JQuery however I'm not sure what is the best approach or way to do it. Does anyone have any spare time to educate me on this, I've never written Ajax or JQuery code before, trying to do this in php alone does not seem like a solution. Thank you in advance
  9. UPDATE 2: Well Finally got this to work. I needed to add some hidden input fields so they would "form post" to my functions page then I was able to call the variable and display on my auto email. Your suggestions are very interesting; I will keep these in mind as alternative methods. Thank you again
  10. Update: I got the email to populate in the mail() function by creating a. SQL statement and making the query unique. My new problem now is that in the $message it is grabbing the variables due them being posted from the form but I'm trying call dbase columns to grab a few extra field for the $message template. I suppose due to them not being called from the post form it's not calling the data. I even did another SQL statement but not working. Very frustrating :-/. Let me know if I need to elaborate further. I really appreciate your time. Thank you
  11. Hello, I'm running php using classes and here's my dilema. I have a web form that pull data from an MySQL database as a <SELECT> <OPTION> drop down as a while loop; I have two while loops and no problem getting data for each. I have no problem calling the data for the <OPTION> however I need to pull two pieces of information and the <OPTION> from what I know only pulls one. The second while loop from the "sender" table has a "sender_name" & "sender_email". My problem is I can only have one value in the <OPTION> tag but I need to $POST two variables. when I select my drop down which only displays "sender_name" I would like to post "sender_email" so that I can echo this in my functions page for other things. My MySQL table for "sender" has the following: sender_id, sender_name, sender_email Plan is to create an Entry Form > Form Submitted > Data is run and verified on functions page > if Good execute code and send email to sender with details of the entry data... Currently I have it working if I enter a static email address in the mail() function however I would like when the Entry Form is filled out for it to pull the "sender_email" from the associated "sender_name" on that table as a variable to the functions page which has a mail() script Should I be using JavaScript or another PHP function? Thank you in advance, my code below My form: <form method="post" action="form-post.php"> <input type="hidden" name="add-tracking" value="true" /> <input type="hidden" name="tracking_method_id" id="tracking_method_id" value="2" /> <table> <tr> <td><label for="tracking_number">Tracking Number:<br />(No Dashes)</label></td> <td><input type="text" name="tracking_number" id="tracking_number" /></td> </tr> <tr> <td><label for="tracking_recepient">Tracking Recepient:</label></td> <td><input type="text" name="tracking_recepient" id="tracking_recepient" /></td> </tr> <tr> <td><label for="tracking_date">Tracking Date:<br />(YYYY-MM-DD)</label></td> <td><input type="text" name="tracking_date" id="tracking_date" value="<?php echo date('Y-m-d');?>" /></td> </tr> <tr> <td><label for="tracking_cost">Cost $:</label></td> <td><input type="text" name="tracking_cost" id="tracking_cost" value="0.0000" /></td> </tr> <tr> <td><label for="tracking_dept">Dept:</label></td> <td><select name="tracking_dept" id="tracking_dept"> <option value=""></option> <?php $sql = "SELECT * FROM department"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res)) { echo '<option value="' . $row['dept_name'] . '">' . $row['dept_name'] . '</option>';} ?> </select></td> </tr> <tr> <td><label for="tracking_requestor">Requested By:</label></td> <td><select name="tracking_requestor" id="tracking_requestor"> <option value=""></option> <?php $sql1 = "SELECT * FROM sender"; $res1 = mysql_query($sql1) or die(mysql_error()); while($row1 = mysql_fetch_assoc($res1)) { echo '<option value="' . $row1['sender_name'] . '" $row1>' . $row1['sender_name'] . '</option>'; } ?> </select></td> </tr> <tr> <td colspan="2"><input type="submit" name="submit" value="Submit" /></td> </tr> </table> </form> My Function function add_tracking($p) { $tracking_id = mysql_real_escape_string($p['tracking_id']); $tracking_number = mysql_real_escape_string($p['tracking_number']); $tracking_recepient = mysql_real_escape_string($p['tracking_recepient']); $tracking_date = mysql_real_escape_string($p['tracking_date']); $tracking_cost = mysql_real_escape_string($p['tracking_cost']); $tracking_dept = mysql_real_escape_string($p['tracking_dept']); $tracking_requestor = mysql_real_escape_string($p['tracking_requestor']); $tracking_method_id = mysql_real_escape_string($p['tracking_method_id']); $tracking_number = preg_replace('/[^a-zA-Z0-9s]/', '', $tracking_number); $headers = ""; $headers .= "From: Anaheim Receiptionist <anaheimreceptionist@powerplus.com>\n"; $headers .= "X-Sender: anaheimreceptionist@powerplus.com\n"; $headers .= "X-Mailer: PHP\n"; $headers .= "X-Priority: 3\n"; $headers .= "Content-Type:text/html; charset=\"iso-8859-1\"\n"; $message = ' <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <style type="text/css"> .right {text-align: right; min-width: 150px;} * {font-family: arial, tahoma, "Times New Roman";} body {font-size: 15px;} #wrap {width:550px; margin: 0 auto;} </style> </head> <body> <div id="wrap"> <p><h1>Your Shipping Item Is Scheduled For Delivery</h1></p> <p><h3>Below Is Your Details:</h3></p> <div style="border: 1px solid #000000;"> <table cellpadding="5"> <tr> <td class="right">Date: </td><td>' . $tracking_date . '</td> </tr> <tr> <td class="right">Sent To: </td><td>' . $tracking_recepient . '</td> </tr> <tr> <td class="right">Tracking Number: </td><td><a href="' . $row1['method_link'] . $tracking_number . '">' . $tracking_number . '</a></td> </tr> <tr> <td class="right">Department No: </td><td>' . $tracking_dept . '</td> </tr> <tr> <td class="right">Sent By: </td><td>' . $tracking_requestor . '</td> </tr> </table> </div> </div> </body> </html> '; if(!$tracking_number || !$tracking_recepient || !$tracking_date || !$tracking_cost || !$tracking_dept || !$tracking_requestor): if(!$tracking_number): echo '<p>The Tracking Number is required</p>'; endif; if(!$tracking_recepient): echo '<p>The Recepient Name is Required</p>'; endif; if(!$tracking_date): echo '<p>The Tracking Date is Required</p>'; endif; if(!$tracking_cost): echo '<p>The Tracking Amount is Required</p>'; endif; if(!$tracking_dept): echo '<p>The Tracking Dept is Required</p>'; endif; if(!$tracking_requestor): echo '<p>The Requested By Name is Required</p>'; endif; echo '<p><a href="tracking-method.php">Try again!</a></p>'; else: $sql = "INSERT INTO tracking VALUES (null, '$tracking_number', '$tracking_recepient', '$tracking_date', '$tracking_cost', '$tracking_dept', '$tracking_requestor', '$tracking_method_id')"; $res = mysql_query($sql) or die(mysql_error()); echo '<p>Added Sucessfully</p>'; echo '<p><img src="ok.png" />'; echo '<p><a href="index.php">Go Back to Tracking # Table</a></p>'; mail($sender_email, 'Your Tracking ID: ' . $tracking_number, $message, $headers); endif; }
  12. This worked.. Thank you for your help. Very much appreciated
  13. Thank you...I forgot to remove the "ink". I tried the date function but I keep getting a php error // print 'em print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n"); print("<TR><TH><a style='float:left;' href='/joe'>Go Back Home</a></TH><TH></TH><TH></TH><TH></TH></TR>\n"); print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th><th>Modified</th></TR>\n"); // loop through the array of files and print them all for($index=0; $index < $indexCount; $index++) { if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>"); print("<td>"); print(filetype($dirArray[$index])); print("</td>"); print("<td>"); print(filesize($dirArray[$index])); print("</td>"); print("<td>"); print(filemtime(date('F d Y H:i:s', $dirArray[$index]))); print("</td>"); print("</TR>\n"); } } print("</TABLE>\n"); This doesn't seem to work, I'm wondering if I need to delare it first some where or a variable. The problem is I'm already printing an array and not sure how to format the array of a file into date format. Anyother ideas?
  14. Hello All, I'm trying to show the modication date of a file with php output. I added the "filemtime" to the print() function but I want it to show the date and time rather than just numbers. Any help would be greatly appreciated Here's my source: <style type="text/css"> * { font-family: tahoma; font-size: 16px; } </style> <?php // open this directory $myDirectory = opendir("."); // get each entry while($entryName = readdir($myDirectory)) { $pathinfo = pathinfo($entryName); if($pathinfo['extension'] != 'php, ink') $dirArray[] = $entryName; } // close directory closedir($myDirectory); // count elements in array $indexCount = count($dirArray); Print ("$indexCount files<br>\n"); // sort 'em sort($dirArray); // print 'em print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n"); print("<TR><TH><a style='float:left;' href='/joe'>Go Back Home</a></TH><TH></TH><TH></TH><TH></TH></TR>\n"); print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th><th>Modified</th></TR>\n"); // loop through the array of files and print them all for($index=0; $index < $indexCount; $index++) { if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>"); print("<td>"); print(filetype($dirArray[$index])); print("</td>"); print("<td>"); print(filesize($dirArray[$index])); print("</td>"); print("<td>"); print(filemtime($dirArray[$index])); print("</td>"); print("</TR>\n"); } } print("</TABLE>\n"); ?> Thank you all in advance
×
×
  • 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.