Jump to content

atticus

Members
  • Posts

    176
  • Joined

  • Last visited

Everything posted by atticus

  1. Bradem, please give more details about the search. Do you want the pages found in the search to have the link id, or the actual search results page.
  2. Alright, the mail() is working fine until I add more than five input fields to be sent. The error I received said that php imposes a limit of five for the mail() function. My solution was to create a string of the information and just send the string. However, I think I have the syntax wrong. Any suggestions would be great, thanks. <?php $email = $HTTP_POST_VARS['email']; $subject = $HTTP_POST_VARS['subject']; $message = $HTTP_POST_VARS['message']; $customeremail = $HTTP_POST_VARS['customeremail']; $address1 = $HTTP_POST_VARS['address1']; $address2 = $HTTP_POST_VARS['address2']; $city = $HTTP_POST_VARS['city']; $state = $HTTP_POST_VARS['state']; $zip = $HTTP_POST_VARS['zip']; $content = $address1 $address2 $city $state $zip; ... elseif (mail($email,$subject,$customeremail,$message, $content )) {
  3. alright, figured it out. Here is the solution: $newstring = substr($description,0,150); echo $newstring
  4. wouldn't that just limit the amount of rows from mysql, I would actually just like to display the first 150 characters from 1 database field(row).
  5. Hi, I am trying to figure out the best way to limit the amount characters displayed in a result with php from a mysql database. For example, when a user clicks on the category and a list of products are shown, I would like to display the first 150 characters from the field in the database about that product with "..." following. I am a noob to php and I am not really sure where to start with this one. Thanks in advance.
  6. how can I drop it out when I display information back on the website to the user?
  7. When I insert data into mysql from a form, I keep getting this problem when the data is displayed "we're" is turned into "we/'re". I am inserting the data into a varchar type field.
  8. Hi all, I am using shared hosting and I do not have access to the server and I am trying to use php to gzip my components. I know my server is ablt to gzip because I have a version of zen-cart installed on it and it gzips the components. Its just not working. <?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
  9. The file is uploading to the server, however in order to keep files from being overwritten I want to generate a random file name. It is uploading to the file, however it is not generating the random name. <?php include("config.php"); if(isset($_POST['submit'])) { $uploadDir = 'upload/'; $id = mysql_escape_string($_POST['id']); $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // generate the random file name $randName = md5(rand() * time()); $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; }
  10. Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in Line error: $sql = "SELECT cat_Id FROM CATEGORY WHERE cat_Name = $_POST['cat_Name']"; entire query: $sql = "SELECT cat_Id FROM CATEGORY WHERE cat_Name = $_POST['cat_Name']"; $query = mysql_query($sql); $row = mysql_fetch_array($query); Something is wrong with WHERE b/c it works w/o it
  11. There is no reason to do do this, or to use XHTML. XHTML is useful because it allows easy integration of XML, which is very useful and the future of database applications in web sites. Secondly, it is much cleaner and the search engines prefer the code to content ratio. I recently redesigned a website in xhtml/css and saw it jump to the top ten in Google with in a month.
  12. How do you change the image in the url bar and on the tabs in mozilla and IE. (for example: the image that is on this site right before the http://www.phpfreaks.com) Is it a script or html, css or what. Thanks in advance
  13. thanks everybody and I appreciate the link... $sql = "SELECT * FROM `order` WHERE cust_id = $id AND processed = 'yes' AND DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= processeddate ORDER BY processeddate DESC, last_name ASC";
  14. noob question I know ??? How do I order the following search to return only records processed in the last 30 days? <?php echo "<h3>Subjects Searched in Last Thirty Days:</h3><center> <table border=1 style=\"border-collapse:collapse;\"> <tr> <th style=\"padding-right:5px;\">Last Name, First Name</th> <th style=\"padding-right:5px;text-align:center;\">Processed (yyyy - mo - dy)</th> </tr> "; $sql = "SELECT * FROM `order` WHERE cust_id = $id AND processed = 'yes' ORDER BY processeddate DESC, last_name ASC"; $query = mysql_query($sql) or die('Error, query failed : ' . mysql_error()); while($row = mysql_fetch_array($query)) { echo "<tr> <td>".$row['last_name'].", ".$row['first_name']."</td> "; echo "<td style=\"text-align:center;\">".$row['processeddate']."</td> </tr>"; } echo "</table></center>"; ?>
  15. what is md5...I am using the mysql PASSWORD when I put the info into the database
  16. Hi all... I am having a problem with a login function. I cannot find any errors and I am receiving no errors from mysql or php. It just simply says "wrong username and password". I have double and triple checked my database and created multiple users (using the password field for password of course) and I still can't find the problem. Here is the function: function doLogin() { // if we found an error save the error message in this variable $errorMessage = ''; $userName = $_POST['txtUserName']; $password = $_POST['txtPassword']; // first, make sure the username & password are not empty if ($userName == '') { $errorMessage = 'You must enter your username'; } else if ($password == '') { $errorMessage = 'You must enter the password'; } else { // check the database and see if the username and password combo do match $sql = "SELECT user_id FROM tbl_user WHERE user_name = '$userName' AND user_password = PASSWORD('$password')"; $result = dbQuery($sql) or die (mysql_error()); if (dbNumRows($result) == 1) { $row = dbFetchAssoc($result); $_SESSION['plaincart_user_id'] = $row['user_id']; // log the time when the user last login $sql = "UPDATE tbl_user SET user_last_login = NOW() WHERE user_id = '{$row['user_id']}'"; dbQuery($sql) or die (mysql_error()); // now that the user is verified we move on to the next page // if the user had been in the admin pages before we move to // the last page visited if (isset($_SESSION['login_return_url'])) { header('Location: ' . $_SESSION['login_return_url']); exit; } else { header('Location: index.php'); exit; } } else { $errorMessage = 'Wrong username or password'; } } return $errorMessage; } /* Logout a user */ function doLogout() { if (isset($_SESSION['plaincart_user_id'])) { unset($_SESSION['plaincart_user_id']); session_unregister('plaincart_user_id'); } header('Location: login.php'); exit; } a portion of the form: <form method="post" name="frmLogin" id="frmLogin"> <p> </p> <table width="350" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#336699" class="entryTable"> <tr id="entryTableHeader"> <td>:: Admin Login ::</td> </tr> <tr> <td class="contentArea"> <div class="errorMessage" align="center"><?php echo $errorMessage; ?></div> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="text"> <tr align="center"> <td colspan="3"> </td> </tr> <tr class="text"> <td width="100" align="right">User Name</td> <td width="10" align="center">:</td> <td><input name="txtUserName" type="text" class="box" id="txtUserName" value="admin" size="10" maxlength="20"></td> </tr> <tr> <td width="100" align="right">Password</td> <td width="10" align="center">:</td> <td><input name="txtPassword" type="password" class="box" id="txtPassword" value="admin" size="10"></td> </tr> <tr> <td colspan="2"> </td> <td><input name="btnLogin" type="submit" class="box" id="btnLogin" value="Login"></td> Again...I am not getting any errors such as unknown columns or unknown tables...any suggesstions?
  17. thanks for the help...worked perfectly the FIRST time.
  18. Noob Question: I want to query mysql to produce the following flow: -User1 - User1 order1 - User1 order2... -User2 - User2 order1 -User3 - User3 order1 and so on... My problem is that when I make the user a while, it displays all the names of the users and than displays the orders. This produces one User record correctly $sql1 = "SELECT client.*,`order`.cust_id FROM `client`,`order` WHERE client.cust_id = `order`.cust_id"; $query1 = mysql_query($sql1); $row = mysql_fetch_array($query1); $id = $row['cust_id']; echo $row['last_name']; $sql = "SELECT * FROM `order` WHERE cust_id = $id ORDER BY time"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "<h4>".$row['last_name']." </h4><br />"; } ?> How do I wrap the whole thing in a while so it repeats the user and second while again?
  19. alright, I added it into my query, but still getting same results: $query = "INSERT INTO `order` (type_service, notes, agree, time) VALUES ( '$type_service', '$notes', '$agree','NOW()');";
  20. I want date and time, or at least date.
  21. Hi all, I am trying to get a timestamp onto records as they are submitted into the mysql database. I have field in mysql that is "timestamp" called time. this is a portion of the php code I am using. I don't think I am using the date() function correctly. It doesn't error out but the timestamp in the database is all 0's. $stamp = $date(Y-m-d,H-i-s); I did not put this into the form, but created the variable after the form is submitted so the variable can go directly into the database.
×
×
  • 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.