Jump to content

gwood_25

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Everything posted by gwood_25

  1. Hello, I have a function that duplicates records in a database then takes the user to an edit form. This function works fine until a record with an apostrophe is encountered and then it breaks. I have tried to implement the mysql_real_escape_string() function but it still gives the same error. Here is my code: // Get the ID of the product to duplicate $ID = $_GET['ID']; $sql = "select products.* from products where ID=$ID"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result,MYSQL_ASSOC); // Load the values of the record to duplicate $SubCategoryID = $row['SubCategoryID']; $BrandID = $row['BrandID']; $Name = $row['Name']; $Price = $row['Price']; $Keywords = $row['Keywords']; $Description = $row['Description']; $Image = "noimage.png"; // Create a new record in the database and populate it with the values from the record to be duplicated $sql = sprintf("Insert Into products (SubCategoryID, BrandID, Name, Price, Keywords, Description, Image) Values ('$SubCategoryID', '$BrandID', '$Name', '$Price', '$Keywords', '$Description', '$Image')", mysql_real_escape_string($SubCategoryID), mysql_real_escape_string($BrandID), mysql_real_escape_string($Name), mysql_real_escape_string($Price), mysql_real_escape_string($Keywords), mysql_real_escape_string($Description), mysql_real_escape_string($Image)); mysql_query($sql) or die(mysql_error()); // Get the ID for the newly inserted record $ID = mysql_insert_id(); $link = "edit_product.php?ID=".$ID; // Take the user to the edit screen to edit the details of this product header("Location:".$link); mysql_close($dbh); I'm sure i've done something wrong but unfortunately i'm very new to php and don't know why it's not working
  2. the code i have and that you modified for me should work under normal circumstances, however, yahoo doesn't allow you to send email via script that has a return address who's domain is outside of your hosted domain. If the return address domain is outside of the hosted domain, a default return address is used instead. This is a yahoo specific setting and is inteded for anti-spam measures. Thank you again for your help.
  3. Thank you so much for your help. I'm not sure if maybe this is a yahoo issue and they don't allow you to change this setting?
  4. ok, but the original question still remains.... why won't the "from" address in my mail client appear as the email addy submitted via the web form. It always displays as info@domain.com ... I can't change it. The reason I want to change it is so that I can easily reply to a customer message without copying and pasting.
  5. I tried running your code and it didn't work. When I put the dots back in... it worked.
  6. removing the dots breaks the script. The dots are required for concatenation aren't they? Please bear with me I am very new to php and I am not sure what the issue is. I am able to send mail successfully with my original script, it just won't change the from address or teh reply to address. This site is hosted with yahoo and runs on a linux server does this make a difference?
  7. Hello, I have a strange problem that I'm not sure how to solve. I have a web form that collects name, email and message from users of my website. This info is posted to a php script which then emails the info to our email address. The problem is, the from address never gets changed from webmaster@ourdomain.com. I haven't specified this address in the script at all and am adding extra headers to try and change the from address to the email addy specified by the user....here is my script. Any help is greatly appreciated. <?php header("Cache-Control: no-cache, must-revalidate"); $mail_to= "info@mysite.com"; //address I want the website emails going to $Name =$_GET['Name']; $mail_from=$_GET['Email']; $mail_sub="Message from Wheatcity Cowtown Website"; $mail_mesg=$Name."<".$mail_from."> wrote: \n\n".$_GET['Message']; $headers = $mail_from."\r\n"."Reply-To:".$mail_from."\r\n"; if(mail($mail_to,$mail_sub,$mail_mesg,$headers)) { echo "<br><br><p align=center>E-mail has been sent successfully</p>"; } else { echo "<br><br><p align=center>Failed to send the E-mail, please try again or contat us info@wheatcitycowtown.com</p><br>"; } ?>
  8. Thank you so much. That worked perfectly.
  9. ok, I am very new to php so how do I do that and do I have to do it each time I upload a file? Where in the code should the chmod command go?
  10. hello, I am uploading an image to my web host and am storing a reference to the file in a mysql database. The file upload works and the reference to the image is stored in the db. However viewing the image generates an "unauthorized" error. I was told by the host that this was a problem with my php script and not setting permissions on the uploaded file via script. I have reasearched this and to the best of my knowledge I need to use the chmod command. Following is my code, at what point to I call chmod? Any help is greatly appreciated. $pic=($_FILES['photo']['name']); if($pic != "") { //Writes the information to the database mysql_query("INSERT INTO `brands` (Name, Weblink, Image) VALUES ('$name', '$weblink', '$pic')") or die(mysql_error()); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { chmod($_FILES['photo']['tmp_name'],0755); //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the database"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } } else { //Writes the information to the database mysql_query("INSERT INTO `brands` (Name, Weblink, Image) VALUES ('$name', '$weblink', 'noimage.png')") or die(mysql_error()); } mysql_close($dbh); ?>
  11. yes I can see the file in yahoo's file manager. However, attempting to view the file give the "unauthorized" error message.
  12. That's the problem. I cannot see them. This site is being hosted on yahoo and using their file manager the only thing i can see is that the folder is a public folder. Also, I have uploaded images with the same script on multiple client machines running different OS's (vista, xp, mac os 10.x) and get the same result. I am suspecting that this is a yahoo problem that I would not have access to change even if I wanted to. Also, they are blaming the script for not setting the appropriate permissions? I don't get that. How unsecure would that be if a script was allowed to change permissions for a file or directory? Can I safely assume that if my script is putting the files where they are supposed to and successfully writing to the db that my script is not the problem? Again, thank you for your help.
  13. Hello, I have a php upload script that stores a reference to an image in a mysql database and uploads the image to a specified directory. I am hosting a site on yahoo and the script uploads the image successfully and stores the appropriate data in the database without a problem. However, when I go to view the image, i get an "unauthorized" error returned from the webserver. If I upload an image with yahoo's online file manager, I have no problems. Forcing users to use the yahoo file manager is not acceptable. Yahoo is blaming my script stating that my script is the problem. If that is true, what could the problem with the script be? I personally think this is a permissions issue on their side. Any advice would be greatly appreciated.
  14. ok I tried the code you provided...same result. blank page and bottom link is not rendered. How can I output an error message if any to see where the problem is?
  15. not sure if this helps but here is the directory structure.... the scripts to upload and add to db are located here... root/admin/brands/add.php the images are being uploaded to here.... root/brand_images/ There seems to be something wrong with the query as even when I only try to insert a record....using only the insert query...same result...blank page and bottom link doesn't get rendered I'm sure there is something very simple that I am doing. Also important to note that in the same brand directory is a script that uses the same connection include and it connects to the db and displays a listing of brands without a problem.
  16. Here is the form page code.... <form name=form1 enctype="multipart/form-data" action="add.php" method="POST" onsubmit="return frmValidate();"> <table align=center> <tr><td> <div class="box"> <div class="bi"> <div class="bt"><div></div></div> <div class="left"><h1>Add Brand Record</h1></div> <p> <table align=center> <tr> <td>Name:</td> <td><input type=text name=Name style="width:300" maxlength:200 /></td> </tr> <tr> <td>Weblink:</td> <td><input type=text name=Weblink style="width:300" maxlength:200 /></td> </tr> <tr> <td>Image:</td> <td><input type=file name=Image style="width:300" /></td> </tr> </table> </p> <div class="bb"><div></div></div> </div> </div> </td></tr> <tr> <td align=right> <input type=button value="Cancel" class=btn onClick="document.location.href='brand_list.php'" /> <input type=submit value="Save" class="btn" /> </td> </tr> </table> </form>
  17. I removed that second query but still nothing gets inserted into the db and no error is generated....the page is blank after the script is completed. Also, the very last line never gets rendered to the browser
  18. Hello, first I want to thank you guys for all of your help. I am new to php and I am having a problem uploading an image and storing a reference to the image name in a mysql database. I know my code may not be the best but if you could tell me what is wrong it would be greatly appreciated. The problem I am having, is that the image is never uploaded and no error is generated. Also the record is never inserted into the databae either. What am I doing wrong? here is my code..... also, the very bottom line which displays a link, never gets rendered to the browser leading me to believe there is an error but I can't see what it is.... I am hosting this site on yahoo servers and am not sure if perhaps there is a permissions issue on the target forlders? But why won't the query insert records into the database either? <?PHP header("Cache-Control: no-cache, must-revalidate"); include '../connection.php'; //This gets the information from the form $name=$_POST['Name']; $weblink=$_POST['Weblink']; $pic=($_FILES['Image']['name']); if($weblink = "") { $weblink = "none" } //We are uploading a picture if($pic != "") { //This is the directory where images will be saved $target = "../../brand_images/"; $target = $target . basename( $_FILES['Image']['name']); //Writes the information to the database mysql_query("INSERT INTO `brands` (Name, Weblink, Image) VALUES ('$name', '$weblink', '$pic')") or die(mysql_error()); //Writes the photo to the server if(move_uploaded_file($_FILES['Image']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } } else //No picture being uploaded { //Writes the information to the database mysql_query("INSERT INTO `brands` (Name, Weblink, Image) VALUES ('$name', '$weblink', 'noimage.png')") or die(mysql_error()); } mysql_close($dbh); ?> <br /> <center><a href="brand_list.php">Back</a></center>
  19. Thank you for all of your help. I feel very dumb now. I added ..... die(mysql_error() . " " . $sql); and the problem was the connection.php file.... it contained a misspelled password. It works fine now. also, the error with the code provided by thorpe was that the last line .... die(mysql_error() . " " . $sql; was missing a closing ) Again, thank you for all of your help. I am truly sorry if I wasted you time. However, being a newbie, I guess that is how you learn sometimes.
  20. this code......... <?PHP session_start(); header("Cache-Control: no-cache, must-revalidate"); include 'connection.php'; $User = $_POST["user"]; $Pass = $_POST["pass"]; $sql = "select ID, FirstName, LastName from users where users.UserName ='".$User."' and users.Password ='".$Pass."'"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows >0) { $_SESSION['User'] = $row['FirstName']." ".$row['LastName']; header("Location:".$link); } else { session_destroy(); echo "User:".$User."<br>"; echo "Pass:".$Pass."<br>"; echo "Query:".$sql."<br>"; echo "Rows:".$num_rows; } ?> produces this result.......... User:jkish Pass:test Query:select ID, FirstName, LastName from users where users.UserName ='jkish' and users.Password ='test' Rows: why is the result empty? When I run that query directly against the db it works fine and returns this....... ID FirstName LastName 1 Jocelyn Kish Thank you again for all of your help. This has me stumped
  21. I have friendly error messages turned off.... here is the error I get when I use your code.... Server Error in Application "Default Web Site/wcc" -------------------------------------------------------------------------------- HTTP Error 500.0 - Internal Server Error Description: The page cannot be displayed because an internal server error has occurred. Error Code: 0x00000000 Notification: ExecuteRequestHandler Module: IsapiModule Requested URL: http://localhost:80/wcc/admin/authenticate.php Physical Path: D:\wwwroot\wcc\admin\authenticate.php Logon User: Anonymous Logon Method: Anonymous Handler: PHP Most likely causes: IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred. IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly. IIS was not able to process configuration for the Web site or application. The authenticated user does not have permission to use this DLL. The request is mapped to a managed handler but the .NET Extensibility Feature is not installed. What you can try: Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account. Check the event logs to see if any additional information was logged. Verify the permissions for the DLL. Install the .NET Extensibility feature if the request is mapped to a managed handler. Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here. More Information... This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error. Microsoft Knowledge Base Articles: 294807 -------------------------------------------------------------------------------- Server Version Information: Internet Information Services 7.0.
  22. Thank you for your help. it is very much appreciated as I am new to PHP. However, I get an internal server error when I run your version of the code. Not sure why. I am running IIS7 and vista ultimate and PHP Version 5.2.4
  23. Hello, I have a simple login form that passes its variables to a php script to authenticate a user and redirect to the appropriate page. The problem is the redirect is not working even when I hard code a valid username and password into the query. I know the query works because I have tested the sql statement against the db and it returns the correct result. My code is below... <?PHP session_start(); header("Cache-Control: no-cache, must-revalidate"); include 'connection.php'; $User = $_POST["user"]; $Pass = $_POST["pass"]; $result = mysql_query("select ID, users.FirstName, users.LastName from users where users.UserName ='".$User."' and users.Password ='".$Pass."'"); $num_rows = mysql_num_rows($result); if($num_rows >0) { $_SESSION['User'] = $row['FirstName'] + " " + $row['LastName']; $link = "main.php"; } else { session_destroy(); $link = "login.php"; } header("Location:".$link); ?> Please note... I am always returned to the login.php page regardless of whether or not I hard code a valid username and password into the query. Thank you in advance
  24. sorry I meant to say I changed the braces to brackets and still had the issue.... when I added the semi colon... it worked. Thanks again for your help. Much appreciated
×
×
  • 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.