Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

ChatGPT 🤖

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Everything posted by ChatGPT 🤖

  1. Umm...maybe I didn't explain it clearly...but 10Mb is the size per file uploaded through HTTP; however, there is no file size limit at all for files uploaded through FTP.
  2. Hi scootstah, thanks for your reply. So you are saying what the server determines the file size limit is by the front-end, not the approach where the file is going into? Let me put this also into circumstance: The form itself is not on the same server, the form itself is on another server with another web hosting company.
  3. Dear all, I'm working on a website that is hosted on a server with 10Mb of file size limit via HTTP file uploading approach (eg. PHP file uploading form using move_uploaded_file()), although there's no file size limit via FTP file uploading approach (eg. Using FTP client). Therefore, I was thinking about using PHP FTP functions to bypass the file size limit. However, when I upload file bigger than 10Mb, I still got this error message telling me that my file can't be over 10Mb... So my question is...what exactly are the differences between PHP FTP and FTP Client, that the web server used to determine whether to block the file bigger than 10Mb or not? Thank you very much! Below is my code: <?php echo '<form action="" method="post" enctype="multipart/form-data">'; echo 'Click the Browse button to find the file you wish to upload'; echo '<input type="file" name="add_file">'; echo '<INPUT TYPE="submit" name="upload" value="upload">'; echo '</form>'; if($_POST['upload']) { $add_file = $_FILES['add_file']; //change these values to suit your site $ftp_user_name = 'username'; $ftp_user_pass = 'password'; $ftp_server = 'ftp.domainname.com'; $ftp_root = '/'; //File upload $temp_path = $ftp_root . $add_file['tmp_name']; $target_path = basename($add_file['name']); $max_size = 26214400; if($add_file['error'] == 0 && $add_file['size'] < $max_size) { // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // upload a file ftp_chdir($conn_id, '/root/second/'); if (ftp_put($conn_id, $target_path, $temp_path, FTP_ASCII)) { echo "successfully uploaded " . $target_path; } else { echo "There was a problem while uploading " . $target_path; } } else { echo "There's been an error, please try again later."; } // close the connection ftp_close($conn_id); } ?>
  4. I don't know how you created this page (Whether by programming, or plain HTML), either way...you need the "http://" prefix for your url... The a tag should look like this --> <a href='http://www.facebook.com'>FaceBook<br></a>
  5. So did you have the issue figured out? If not...here's more info for you... On the initial setup of PhpMyAdmin password is not required to access it, but when you do setup a password, you shall be able to see a login page by accessing your PhpMyAdmin, if you don't see this page...it's likely there's something wrong with your config.inc.php setting, and the config.inc.php file should be located in your phpMyAdmin directory. I'm not familiar with WAMP2, but what's your PhpMyAdmin and MySQL version? I can't remember exactly it's PhpMyAdmin or MySQL to blame, but with some older version of the either of them, you will have a to do an Old Password trick to the MySQL command line client somehow...it's also something to look into... Hope these would help!
  6. I'm not a WAMP2 user...but do you have your PHPMYADMIN's config.inc.php set up?
  7. pets2soul

    heeeeeeeelp

    If this is a typo finding game....I would say... $g=$GET_['podrucje_id']; should be $g=$_GET['podrucje_id'];
  8. Dear Keith, Thank you very much! It worked out perfectly! And this is my first time using Foreach, feels good to learn a new thing! Best Regards, AJ
  9. Dear experts, I'm working on a user info updating form, and I only want the amended fields to be updated to the database, I figured this part out, however what caught me is the updating part, where my amended values are stored in an array, and I'm trying to put the values into the SET part with the use of FOR loop, but I can't get the query to work properly...it'd be super duper thankful if anyone can help me with it. Below is my code: $diff_num = count($diff_info); $diff_value = array_values($diff_info); $diff_key = array_keys($diff_info); for($i = 0; $i < $diff_num; $i++) { $db_update = "AND " . $diff_key[$i] . " = '" . $diff_value[$i] . "' "; $query = "UPDATE db_table SET field_one = '$value_one' " . $db_update . " WHERE field_some = '$value_some'"; if (mysql_query($query)) { return true; } else { return false; } }
  10. I would say...LEFT JOIN both tables...like this: SELECT table1.number_x, table2.number_y FROM table1 LEFT JOIN table2 ON table1.userid = table2.userid ORDER BY table1.id ASC
  11. Dear fenway, Thanks for the reply. That was what I figured, however I'm requested to go by the 2nd method - the translation one, and it seems to be the last efficient one. My supervisor was worried that if we go by the duplicate records one, it may overload the MySQL...but personally, I don't think 2000 records (assuming there are 500 products in 4 languages) is too many for a database....well...I don't know~
  12. I think it depends on...what's in the CLID column for the employees not taking any class... Say if CLID column is left empty...then you can put WHERE CLID = "" in another hand, if CLID column is NULL...then... WHERE CLID = NULL That's the simplest way I can think of....hope it helps...
  13. You might wanna try putting: WHERE Publisher_name LIKE '%and%' in your query...hope this helps!
  14. Alright, I was given a third option: 3. 1 product description table, each info be inserted in 4 different columns, such as - columns: id | product_no | product_color_en | product_color_fr | product_color_de | product_color_whatever.... Any suggestions? Thank you!
  15. Dear all, I'm working on an multilingual website, and would like to seek for some suggestions / opinions over the database structure. The current situation is...we are starting up with 4 languages, about 450 products, more languages may be added in the future. So far we came up with 2 database management ideas: 1. Select products from 1 product description table, each product to have 4 entries, each in a different language. 2. Select prodcuts from 1 product description table, each prodcut to have 1 entry in a preset language, and then match the result with a translation table to display product info (Such as product name, colors, elements...etc) in different languages. Base on any relevent experience you might have, which option would you suggest? and why? or is there any other way to do it? Thank you!! Best Regards, AJ
  16. Hello! Dear all, I'm having this problem with PHP Mail From Name, it took me entire day, and still haven't figure out the issue...that is... In "From: ", if I have it in simple email format, such as "From: [email protected]" it works...but when I have it with a From Name, eg. "From: Name <[email protected]>", then it just wouldn't send... I heard that some of the servers just won't parse "Name <[email protected]>", if it is the case...would there be any work around to get that From Name appeared? The code is attached below, any help is deeply appreciated! <?php //For Captcha include("settings.php"); header("Content-Type: text/html; charset=utf-8"); @session_start(); $string = strtoupper($_SESSION['string']); $userstring = strtoupper($_POST['userstring']); @session_destroy(); if (($string != $userstring) || (strlen($string) <= 4)) { header("location:contact_us.php"); exit(); } //PHP Mail starts here $form_name = $_POST["name"]; $form_company = $_POST["company"]; $form_email = $_POST["email"]; $form_phone = $_POST["phone"]; $form_mobile = $_POST["mobile"]; $form_msg = $_POST["msg"]; $form_date = date(Y)."-".date(m)."-".date(d); $form_ip = $_SERVER["REMOTE_ADDR"]; $form_lang = "en"; $fromname = "Name"; $frommail = "[email protected]"; @require("../default_timezone.php"); $con = mysql_connect("host","user","pass"); mysql_query("SET NAMES 'utf8'"); if (!$con) { die("Could not connect: " . mysql_error()); } mysql_select_db("dbname", $con); mysql_query("INSERT INTO tablename (CU_Name, CU_Company, CU_Email, CU_Tel, CU_Mobile, CU_Content, CU_CreateDate, CU_IP, lang) VALUES ('$form_name', '$form_company', '$form_email', '$form_phone', '$form_mobile', '$form_msg', '$form_date', '$form_ip', '$form_lang')"); $message = (" <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"> <tr> <td colspan=\"2\" align=\"left\"><img src=\"contact_logo.gif\" /></td> </tr> <tr> <td colspan=\"2\" align=\"left\"><font style=\"font-size: 12px; color: #000;\">Your email is recceived, a representative will be contacting you soon.</font></td> </tr> <tr> <td width=\"70\" align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Name:</b></font></td> <td width=\"430\" align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_name}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Company:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_company}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Email:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_email}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Phone:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_phone}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Mobile:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_mobile}</font></td> </tr> <tr> <td align=\"left\" valign=\"top\"><font style=\"font-size: 12px; color: #000;\"><b>Message:</b></font></td> <td align=\"left\" valign=\"top\"><font style=\"font-size: 12px; color: #000;\">{$form_msg}</font></td> </tr> </table> "); $subject = "Email Subject"; $mime_boundary = md5(uniqid(mt_rand(), TRUE)); $header = "From: ".$fromname." <".$frommail.">\r\n"; $header.= "To: " . $to . "\r\n"; $header.= "MIME-Version: 1.0\r\n"; $header.= "Content-Type: multipart/mixed; \r\n"; $header.= " boundary=". $mime_boundary . "\r\n"; $content = "This is a multi-part message in MIME format.\r\n"; $content .= "--" . $mime_boundary . "\r\n"; $content .= "Content-Type: text/html; charset=utf-8\r\n"; $content .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $content .= $message. "\r\n"; $to=$form_email; @mail($to, $subject, $content, $header); $to2="[email protected]"; @mail($to2, $subject, $content, $header); echo "<html>"; echo "<head>"; echo "<META HTTP-EQUIV='Content-Type' content='text/html; charset=utf-8'>"; echo "<META HTTP-EQUIV='Refresh' CONTENT='3; URL=http://www.server.com/'>"; echo "</head>"; echo "<body>"; echo "Thank you for contacting us!"; echo "<br />"; echo "Your message is sent."; echo "</body>"; echo "</html>"; ?>
  17. Hey mrMarcus, Thanks so much for pointing that out, I was completely confused, but now I got it!!! It's working now!!!
  18. Hi mrMarcus, Thanks for the reply, I'm listing the HTML, AJAX and PHP below: HTML FORM <form name="theform"> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100" height="24"><font class="t2">Product:</font></td> <td width="100"><font class="t2">Price:</font></td> </tr> <tr> <td height="24"><select name="product" id="product" onclick="doWork();" style="width: 85px; border: 1px solid #CCCCCC;"> <option value="Product1">Product1</option> <option value="Product2">Product2</option> <option value="Product3">Product3</option></select></td> <td><input name="price" id="price" type="text" style="width: 85px; border: 1px solid #CCCCCC;" /></td> </tr> </table> </form> AJAX <script language="javascript" type="text/javascript"> <!-- // Get the HTTP Object function getHTTPObject(){ if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) return new XMLHttpRequest(); else { alert("Your browser does not support AJAX."); return null; } } // Change the value of output field function setOutput(){ if(httpObject.readyState == 4){ document.getElementById('price').value = httpObject.responseText; } } // Implement business logic function doWork(){ httpObject = getHTTPObject(); if (httpObject != null) { httpObject.open("GET", "test1.php?price="+document.getElementById('price').value, true); httpObject.send(null); httpObject.onreadystatechange = setOutput; } } var httpObject = null; //--> </script> PHP <?php $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dbname", $con); $result = mysql_query("SELECT * FROM table"); while($row = mysql_fetch_array($result)) { switch ($_GET['product']) { case "Product1": echo $_GET['price'] = $row['product_price1']; break; case "Product2": echo $_GET['price'] = $row['product_price2']; break; case "Product3": echo $_GET['price'] = $row['product_price3']; break; } } ?>
  19. HELLO all, I'm taking my baby step toward ajax interaction with PHP, this is my first experiment, and it's driving me crazy! What I'm trying to do here is...I have a html form with a "product" field, which is a drop down list of products, by selecting the product, I want it to go through a php to grab the price of the product from the database, and then to throw that price back to the "price" text field on the html page. Below is my ajax and php code...it'd be really appreciated if anyone would give me some guidance!!! Ajax <script language="javascript" type="text/javascript"> <!-- // Get the HTTP Object function getHTTPObject(){ if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) return new XMLHttpRequest(); else { alert("Your browser does not support AJAX."); return null; } } // Change the value of output field function setOutput(){ if(httpObject.readyState == 4){ document.getElementById('price').value = httpObject.responseText; } } // Implement business logic function doWork(){ httpObject = getHTTPObject(); if (httpObject != null) { httpObject.open("GET", "test1.php?price="+document.getElementById('price').value, true); httpObject.send(null); httpObject.onreadystatechange = setOutput; } } var httpObject = null; //--> </script> PHP <?php $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dbname", $con); $result = mysql_query("SELECT * FROM table"); while($row = mysql_fetch_array($result)) { switch ($_GET['product']) { case "Product1": echo $_GET['price'] = $row['product_price1']; break; case "Product2": echo $_GET['price'] = $row['product_price2']; break; case "Product3": echo $_GET['price'] = $row['product_price3']; break; } } ?>
  20. First of all, I'm not the server manager, but I'm sure we have those installed, except phpmyadmin, it IS a pain without it! But with everything else installed there should be no problem setting up a table in a existing MySQL database with something like this: <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create table mysql_select_db("db_name", $con); mysql_query("CREATE TABLE name ( FirstName varchar(15), LastName varchar(15), OrchBand varchar(15), PeopleId varchar(15), PartYear YEAR, CateName varchar(15), Biography LONGBLOB, PicURL varchar(15) )") or die(mysql_error()); echo "Table Created!"; mysql_close($con); ?> Shouldn't it?
  21. Dear all, I'm new to php programming, however, I have experience of successfully setting up a php website on a Unix web server. Recently, it has been very frustrating trying to build a php website on a Windows server. No matter how I try, all the things that seem natural on Unix server became very difficult with Windows server... Such as sending form mail through SMTP, setting up a table in MySQL...all I'm trying to do are basic php functions, but still they just don't work. Are php scripts so different on Windows server from Unix server? Or it's just Windows server that's causing all the problem?? Thanks!
  22. Dear All, I'm trying to make a form mail on an Apache 2.2 on Windows server, I have the php.ini file point to the SMTP server our IT guy provided. But still, the email never come after the form is submitted. I'm not sure if I have missed anything in my code...do I need to tell the handling file to find the SMTP setting in php.ini? I'm attaching my code here...please kindly let me know if anything should be changed. Or if the code seems fine...Appreciate whole lot!!! <?php //change this to your email $to = "[email protected]"; $from = $_POST['email']; $subject = "Audition Application"; $field1 = $_POST['familyname']; $field2 = $_POST['givenname']; $field4 = $_POST['dobdd']; $field5 = $_POST['dobmm']; $field6 = $_POST['dobyy']; $field7 = $_POST['age']; $field8 = $_POST['gender']; $field9 = $_POST['instrument']; $field10 = $_POST['birthplace']; $field11 = $_POST['resicountry']; $field12 = $_POST['passportnum']; $field13 = $_POST['passportis']; $field14 = $_POST['passportex']; $field15 = $_POST['homeaddr']; $field16 = $_POST['homephone']; $field17 = $_POST['mobilephone']; $field18 = $_POST['email']; $field19 = $_POST['schoolname']; $field20 = $_POST['teacher']; $field21 = $_POST['experience1']; $field22 = $_POST['experience2']; $field23 = $_POST['experience3']; $field24 = $_POST['language']; $field25 = $_POST['regdd']; $field26 = $_POST['regmm']; $field27 = $_POST['regyy']; $field28 = $_POST['returnname']; $field29 = $_POST['returnaddr1']; $field30 = $_POST['returnaddr2']; $field31 = $_POST['returnaddr3']; //Dropdown Menu Options switch ($_POST['audition']) { case 1: $audition = 'Bangkok, Thailand'; break; case 2: $audition = 'Beijing, China'; break; case 3: $audition = 'Guangzhou, China'; break; case 4: $audition = 'Hanoi, Vietnam'; break; case 5: $audition = 'Hong Kong'; break; case 6: $audition = 'Kuala Lumpur. Malaysia'; break; case 7: $audition = 'Nagoya, Japan'; break; case 8: $audition = 'Osaka, Japan'; break; case 9: $audition = 'Seoul, Korea'; break; case 10: $audition = 'Shanghai, China'; break; case 11: $audition = 'Singapore'; break; case 12: $audition = 'Taipei, Taiwan'; break; case 13: $audition = 'Tokyo, Japan'; break; case 14: $audition = 'Other'; break; default: $audition = false; break; } if (!$audition) { echo 'Please select a city!'; die(); } //begin of HTML message $message = <<<EOF <html> <style type="text/css"> .font1 {font-family: "Times New Roman", Times, serif; font-size: 12px; color: #000000;} </style> <body> <table width="528" border="1" bordercolor="#CCCCCC" cellspacing="0" cellpadding="0"> <tr> <td height="24"> <font class="font1"><b>Family Name:</b></font></td> <td colspan="2"> <font class="font1"><b>Given Name:</b></font></td> <td> <font class="font1"><b>Audition City:</b></font></td> </tr> <tr> <td height="24"> <font class="font1">$field1</font></td> <td colspan="2"> <font class="font1">$field2</font></td> <td> <font class="font1">$audition</font></td> </tr> <tr> <td height="24"> <font class="font1"><b>Date of Birth:</b></font></td> <td> <font class="font1"><b>Age:</b></font></td> <td> <font class="font1"><b>Gender:</b></font></td> <td> <font class="font1"><b>Instrument:</b></font></td> </tr> <tr> <td height="24"> <font class="font1">$field4 / $field5 / $field6</font></td> <td> <font class="font1">$field7</font></td> <td> <font class="font1">$field8</font></td> <td> <font class="font1">$field9</font></td> </tr> <tr> <td height="24"> <font class="font1"><b>Place of Birth:</b></font></td> <td colspan="3"> <font class="font1"><b>Country of Permanent Residence:</b></font></td> </tr> <tr> <td height="24"> <font class="font1">$field10</font></td> <td colspan="3"> <font class="font1">$field11</font></td> </tr> <tr> <td height="24"> <font class="font1"><b>Passport Number:</b></font></td> <td colspan="2"> <font class="font1"><b>Passport Issue Date:</b></font></td> <td> <font class="font1"><b>Passport Expiry Date:</b></font></td> </tr> <tr> <td height="24"> <font class="font1">$field12</font></td> <td colspan="2"> <font class="font1">$field13</font></td> <td> <font class="font1">$field14</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1"><b>Home Address:</b></font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">$field15</font></td> </tr> <tr> <td height="24"> <font class="font1"><b>Home Phone:</b></font></td> <td colspan="2"> <font class="font1"><b>Mobile Phone:</b></font></td> <td> <font class="font1"><b>Email:</b></font></td> </tr> <tr> <td height="24"> <font class="font1">$field16</font></td> <td colspan="2"> <font class="font1">$field17</font></td> <td> <font class="font1">$field18</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1"><b>School Name:</b></font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">$field19</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1"><b>Major Teacher:</b></font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">$field20</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1"><b>Music Camp/Orchestral Playing Experience:</b></font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">1.</font> <font class="font1">$field21</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">2.</font> <font class="font1">$field22</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">3.</font> <font class="font1">$field23</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1"><b>Language(s) Spoken:</b></font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">$field24</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1"><b>Date:</b></font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">$field25 / $field26 / $field27</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1"><b>Mailing Address</b></font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">Name</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">$field28</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">Address</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">1.</font> <font class="font1">$field29</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">2.</font> <font class="font1">$field30</font></td> </tr> <tr> <td height="24" colspan="4"> <font class="font1">3.</font> <font class="font1">$field31</font></td> </tr> </table> </body> </html> EOF; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; // now lets send the email. mail($to, $subject, $message, $headers); echo "<html>"; echo "<head>"; echo "<META HTTP-EQUIV='Refresh' CONTENT='3; URL=index.html'>"; echo "</head>"; echo "<body>"; echo "Message has been sent!"; echo "<br />"; echo "You are now being sent back to our website."; echo "</body>"; echo "</html>"; ?>
  23. Fantastic!! It's working like a charm now!!! I finally learned to use more than one query... Thank you, cooldude832, you are COOL!
  24. I guess I didn't describe my question well... In this particular page I'm working on...I want it to show the latest entry or entries I have made on my last updating date. For example, say...I made ONE article entry on 2008-07-03, then I want the page to show only this entry... and then...I made THREE entries on 2008-07-06, and I want the page to show the 3 entries... That's why I tried GROUP BY date, but I guess what caught me is...how do I define "last updating date" in php code? and how do I tell it to show only the entry or entries from the last updating date? (The website is not updating daily...)
  25. Hello there, The more pages I'm working, more questions popped up...and I messed up my previous post...so here I am extracting this new question under a new topic... I'm working on a news archive type of website, what I'm trying to do now is to show only the article entries from the latest day...this is what I got in mind: $result=mysql_query("SELECT * FROM news WHERE date BETWEEN '2008-01-01' AND '2008-12-31' GROUP BY date ORDER BY fname DESC LIMIT 1"); I have "date" as one of my database column, in the format of yyyy-mm-dd. However, if I set the LIMIT to be 1, only the ONE last entry would be shown, but what do I do if I have more than one entries made in the same day, and I want to show them all? And if I remove the LIMIT 1, all the entries made from 2008-01-01 to 2008-12-31 would be shown, that's not what I want to do.... What I missed in the code? Thanks thanks!!
×
×
  • 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.