
pioneerx01
Members-
Posts
162 -
Joined
-
Last visited
Everything posted by pioneerx01
-
Is there a way to shorten this function?
pioneerx01 replied to pioneerx01's topic in PHP Coding Help
Ok, Do you see how I define a string as: $first_name = fromuser ($_POST['first_name']); I will do that a lot in the form and the name of the string and the name of the variable are always the same. $first_name = fromuser ($_POST['first_name']); $last_name = fromuser ($_POST['last_name']); $company_name = fromuser ($_POST['company_name']); $city = fromuser ($_POST['city']); If there a way I can call for a function in this manner: fromuser (first_name) instead of: $first_name = fromuser ($_POST['first_name']); in such manner that the function will return processed variable already in string format of: $first_name = $variable; -
I am using this code and it work well: function fromuser ($variable) { $variable = trim(htmlentities($variable, ENT_QUOTES, 'UTF-8')); return $variable; } $first_name = fromuser ($_POST['first_name']); echo "<div class='text_field_description' $first_name_error>First Name: </div> <input name='first_name' type='text' class='text_field' value='$first_name' autocomplete='off'>"; echo "<br/>"; Every time I use $_POST['first_name'] i will also define $first_name. So names will always be the same. So, basically is there a way I can just do this: fromuser (first_name); and function will return processed variable as: $first_name = $variable; I hope I explained myself well. Thanks for input.
-
#1034 - Incorrect key file for table, corrupt table
pioneerx01 replied to pioneerx01's topic in MySQL Help
This is where speak slowly comes in. I am trying to run "myisamchk --safe-recover system.MYI" but it gives me "#1064 - 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 'myisamchk --safe-recover system.MYI' at line 1" -
#1034 - Incorrect key file for table, corrupt table
pioneerx01 replied to pioneerx01's topic in MySQL Help
I can not run that successfully. I it still gives me "#1034 - Incorrect key file for table 'system'; try to repair it" when I try to run it -
#1034 - Incorrect key file for table, corrupt table
pioneerx01 replied to pioneerx01's topic in MySQL Help
Oh, I have no idea. I was not the one who created the table, but I am the one stuck with the problem... -
#1034 - Incorrect key file for table, corrupt table
pioneerx01 replied to pioneerx01's topic in MySQL Help
Yes, I was Google-ing this for two days. I did not find much to help me, including some softwares. MySQL 5.1.56 with MyISAM storage engine. I ma not sure what you mean by table description. -
Hi, I have this problem with one of my tables: "#1034 - Incorrect key file for table 'system'; try to repair it" I tried doing "repair table 'system'" but it still gives me the error. I tried to recover from SQL backups but no luck. I have contacted the host provider and they could not do anything. Thus i ma reaching out to people here, that are probably smarter than the provider, to see if anyone has any way of getting the data from the table back. I am new (1-year) to MySQL so please speak "slowly" thanks
-
Ok so standard query can be written as: SELECT * FROM my_table WHERE specific_field = 'some_term' Is there some query that I can search for 'some_term' in all the fields at once in my_table without defining them in the query? SELECT * FROM my_table WHERE any_field = 'some_term'
-
Hi, I created the code below for uploading anywhere from 1-15 PDF files at once. Originally I was hitting 8M limit and (as per my research) I asked my server admin to expand the post_max_size to 100M. Now he did and I verified it, but somehow now I can not upload more than cca 2MB files. What could be causing that? Thanks $forms = array("form_1", "form_1A", "form_1B", "research_plan", "abstract", "form_1C", "form_2", "form_3", "form_4", "human_consent", "form_5A", "form_5B", "form_6A", "form_6B", "form_7"); foreach ($forms as $form_name) { if ($_FILES[$form_name]['name'] != "") { $allowed_filetypes = array('.pdf','.PDF'); $max_filesize = 104857600; $upload_path = 'upload/'; $extension = substr($_FILES[$form_name]['name'], strpos($_FILES[$form_name]['name'],'.'), strlen($_FILES[$form_name]['name'])-1); $filesize = filesize($_FILES[$form_name]['tmp_name']); $filesize_MB = $filesize / 1048576; $full_name = $_FILES[$form_name]['name']; $filename = "$_REQUEST[project_no] - $form_name$extension"; if (!in_array($extension,$allowed_filetypes)) {$error_1 = "yes";} if (filesize($_FILES[$form_name]['tmp_name']) > $max_filesize) {$error_2 = "yes";} if ($error_1 == "yes") { echo "One or more of the uploaded froms are not in allowed file format. Please upload only <strong>.pdf</strong> files <br/><br/><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);'>"; die (); } if ($error_2 == "yes") { echo "Maximum upload file size of <strong>100MB</strong> has been reached. <br/><br/><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);'>"; die (); } move_uploaded_file($_FILES[$form_name]['tmp_name'],$upload_path . $filename); mysql_query("UPDATE project_registrations SET $form_name = 'yes' WHERE project_no = '$_REQUEST[project_no]'"); } } echo "ISEF files for project number <strong>$_REQUEST[project_no]</strong> have been successfully uploaded."; mysql_query("UPDATE project_registrations SET isef_forms = 'yes' WHERE project_no = '$_REQUEST[project_no]'"); require ("upload_forms_email.php"); echo "<script language='javascript'> window.location.href='search_results.php?project_no=$_REQUEST[project_no]';</script>";
-
I do not what to use query string because I will have to encode each link manually and users can change the defined values themselves.
-
How would I pass variables from one page to another without using forms or $_GET features. Let say I have page (1.php) where If define $secret_phrase = "open sesame";. On that page (1.php) I have multiple html links to multiple pages (2.php, 3.php, ...) if you click on the link to 2.php page I would like to pass the $secret_phrase as well without having it encoded into a link or using forms. Is there a way to do it? Thanks
-
How to make this email code addeptable by servers
pioneerx01 replied to pioneerx01's topic in PHP Coding Help
Yes, it is. -
Hi, I am using the following PHP email code, and when I send it to my Gmail account it works fine, but some servers are blocking this email and are not being received. How can I tweak it to make it more compatible? $headers = "From: $row_o_email[email] \r\n"; $headers .= "BCC: $row_o_email[email] \r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $to = $row_e['email']; mail($to, "subject", " email body ", $headers);
-
Can you look over my code to see why it is not working?
pioneerx01 posted a topic in PHP Coding Help
Hi, I have a registration page (that one works fine) where users register with minimal personal info. They also get to rate 8 categories (see bellow) 1-5. Once they hit submit it all goes into database just fine. I have also created a page for myself where I can recall all data for any registration. All data gets pulled from database correctly. When I change variables and hit submit it does not update the record in the database. I get no errors from the script, but I have narrowed the problem to the recall of categories and the ratings. If I remove them from the update script other info gets stored correctly. Here is how I recall the 8 categories and their user submitted ratings (as well as other info): $category = array('AS','BE','BI','CH','CS','EG','EV','PH'); foreach ($category as $cat) { if ($cat == 'AS') $cat_name = 'Animal Sciences'; if ($cat == 'BE') $cat_name = 'Behavioral & Social Sciences'; if ($cat == 'BI') $cat_name = 'Biology'; if ($cat == 'CH') $cat_name = 'Chemistry'; if ($cat == 'CS') $cat_name = 'Computer Science'; if ($cat == 'EG') $cat_name = 'Engineering'; if ($cat == 'EV') $cat_name = 'Environmental Sciences'; if ($cat == 'PH') $cat_name = 'Physical Sciences'; echo" <tr> <td>$cat_name</td>"; $numbers = array('0','1','2','3','4','5'); foreach ($numbers as $no) { echo "<td><input type='radio' name='$cat' value='$no'"; if ($row[$cat] == $no) echo " checked/>"; else echo "/>"; echo"$no</td>"; }} And here is how I update the record (as well as other info not listed): mysql_query("UPDATE registrations SET AS = '$_POST[AS]', BE = '$_POST[bE]', BI = '$_POST[bI]', CH = '$_POST[CH]', CS = '$_POST[CS]', EG = '$_POST[EG]', EV = '$_POST[EV]', PH = '$_POST[PH]' WHERE ID = '$_POST[iD]' "); Something in my recall code is creating issued for me, but I have no idea what. Thanks -
I am trying to separate a values into independent components. In my case it is a time stamp such as 08-22-2011 18:02. I have seen the code before but I can not remember where or what it is called. Basically I define that this string should be exploded with values being between -, -, ,: and reminders are $day, $month, $year, $hour, $minute. If you can point me in the correct direction I would appreciate it. Thanks
-
Trouble parring single quote through post into table
pioneerx01 replied to pioneerx01's topic in PHP Coding Help
PFMaBiSmAd Thank you it worked. $item = htmlentities($row['item'], ENT_QUOTES, 'UTF-8'); echo "<option value='{$item}'>{$item}</option>"; -
In one of my forms I am calling on all items stored in one table: $query = "SELECT item FROM item_table WHERE "; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {echo "<option value='{$row['item']}'>{$row['item']}</option>";} So, basically I get a drop down menu with choices such as: Bob's Pen, Tom's Pencil, Mark's Paper,... Users get to select one and submit that form which goes into table, but nothing after the quote gets stores so I get: Bob, Tom, Mark,... I know that ' and everything after that gets filtered out because when I directly echo the post I get what is submitted into the database (Bob, Tom, Mark, ...). Will I have to replace ' with something else as it gets submitted and then replace something else back to ' right before it gets stored into a table? Or is there a way I do not know of as to how to do it? Thanks