Jump to content

crazygol4

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by crazygol4

  1. I've got a function that sanitize an array before it goes into a MySQL DB. The code isn't mine, so naturally when it bricks I'm kind of confused on how to fix it. I get the error : Fatal Error : Call to a member function on a non-object in ..... on line 33. Here is where the original function is called: $sql2 = insert("f_name, l_name, c_name, email, address, city, state, zipcode, country, phone, cell, fax, acctype, loginacc, accpass, comments, pending", array($_POST[f_name], $_POST[l_name], $_POST[c_name], $_POST[email], $_POST[address], $_POST[city], $_POST[state], $_POST[zipcode], $_POST[country], $_POST[phone], $_POST[cell], $_POST[fax], $_POST[acctype], $_POST[loginacc], md5('$_POST[accpass]'), $_POST[comments], $pending)); Here is are insert and sanitize functions: function sanitize($var, $quotes = true) { if (is_array($var)) { //run each array item through this function (by reference) foreach ($var as $val) { $val = $this->sanitize($val); } } else if (is_string($var)) { //clean strings $var = mysql_real_escape_string($var); if ($quotes) { $var = "'". $var ."'"; } } else if (is_null($var)) { //convert null variables to SQL NULL $var = "NULL"; } else if (is_bool($var)) { //convert boolean variables to binary boolean $var = ($var) ? 1 : 0; } return $var; } // MYSQL INSERTION FUNCTION //insert values into an database // $rows = column names // $vals = ARRAY of values; // pass a 3rd arg as `true` to prevent sanitization // $db->insert("name, email", array($name, $email)) function insert($rows, $vals, $safe = false) { $vals = ($safe) ? $vals : $this->sanitize($vals); $this->sql = "INSERT INTO {$this->table} ( $rows ) VALUES ("; foreach ($vals as $key => $val) { $this->sql .= ($key > 0) ? ", $val" : "$val"; } $this->sql .= ")"; return $this->query(); } Not exactly sure I'm even calling it right, so I would definitely appreciate any help! BUT If you're going to tell me that I shouldn't be using code that I don't completely understand, save your breath....this is how I learn. BTW, this is line 33 that bricks: $vals = ($safe) ? $vals : $this->sanitize($vals); I dont understand the $a ? $b : $c->function part, and there's not a way to find that just by the equation on a search engine, so if someone could explain what that lines is doing before it calls the function I would appreciate it greatly! Thanks for your time and support! -Mark
  2. Hey guy I appreciate the link, but I do have a fair understanding of floats. I've never set a static right and expanding left float before. The reason I posted on a forum is because I've spent time using what I currently have in front of me trying to achieve a result to no avail. I'm trying to get this thing going because I really can't afford the hours of digging through floatology 101. This could easily be a mistake in coding, and while I appreciate the fact that you want me to fully understand floats, I simply lack the time at this moment as I'm trying to get this site up quickly. If you would like to offer some help, awesome! If not that's cool too. Thanks for your time to post. -Crazygol4
  3. Okay so I've tried to do some research on the topic and I find things that are close but not exact. Here's the issue: I have two divs that I want to be side-by-side...but I want the right div "sidebar" to have a static width (200px) and the left "maintextarea" to resize with the browser width (scaled on %). I've even changed the sidebar to resize slightly based on %, but to no avail. My attempts so far have produced either a page that floats properly, but maintextarea resorts to its min-width at all time, or I can get it to resize by removing float from maintextarea, but then sidebar isn't side-by-side with it. So, Is this even possible to have a resizeable float? If so, I could definately use Tips/Suggestion/Code plz Here is my CSS for the divs: #maintextarea { float: left; min-width: 660px; max-width: 960px; margin-right: 0px; margin-left: 0px; padding-left: 6px; padding-top: 6px; padding-right: 6px; padding-bottom: 6px; background-color:#666666; } #sidebar { float: right; margin-top: 0px; margin-right: 0px; margin-left: 0px; min-width: 200px; max-width: 29%; background-color: #0033FF; padding-top: 10px; padding-left: 6px; } Thx for your help! -crazygol4
  4. Hey thanks for all the replies.... yeah I was using ./images/ trying to get to my parent. Thanks for the tip! -Mark
  5. Super newb question I know....but I created a script to upload pics and I need it to save up a couple of directories rather than the one it's in. Example: Scripts location: www/PHPScripts/secured/show_addpic.php Pic upload destination: www/images/rustic/ So what do I type in before '/images/' to make it go back a directory first? Thanks in advance for any help. -Mark
  6. Yeah I already modified the if statement at the top because it wasn't displaying.....but the issue I'm having ATM is that my file upload section isn't showing up. suggestions?
  7. In this particular code I need it to decypher whether or not the user has entered information and then choose which html layout to give the page...so I have to have alot of HTML in the PHP. Also the code you sent breaks up all of the HTML that I want contained in the variable $pagedisp.
  8. Okay problem solved, I have a work-around now. I've subbed the isset line with this: if($_POST[submitted] == !NULL) Thats bizarre though...I didn't realize that it cared so much about what was contained within a variable. Any ideas?
  9. Good suggestion...I tried it a bit earlier and got another parse: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/g/a/r/gardenrelics/html/PHPscripts/do_addinv3.php on line 133
  10. if(isset($_POST[\"submitted\"])){ I've noticed some other people having problems with 'isset' . Could that possibly be the issue?
  11. LoL I was just thinking the same thing. Who knows, it might do the trick for him if he was trying to emulate Pong for Atari. -Mark
  12. I'm having a problem with a PHP parse error coming from a variable and I can't tag down the source of the issue. I'm not extremely experienced in PHP which may very well be the problem, but I have exhausted every measure I know to fix the issue and nothings working. I'm not sure why it's throwing back an error from a variable...I thought that as long as I had everything in the parentheses it would take it for surface value and not examine the code within it. I also have put slashes in front of all of the parentheses within the variable. Let me show you what I'm getting: Parse error: parse error, unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/g/a/r/gardenrelics/html/PHPscripts/do_addinv3.php on line 133 I won't include all of my code since it is rather lenghty, but I will include the part that relates the most. I have also tryed to make line 133 stand out a bit...it's more towards the bottom: //IF user hasn't yet submitted information if ($_POST[part_num] == NULL || $_POST[part_name] == NULL) { $pagedisp == "<h1>Add an item to inventory</h1> <FORM METHOD=\"POST\" ACTION=\"do_addinv3.php\"> <P><em>General Information:</em></P> <P><STRONG>Part Number:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"part_num\" SIZE=14 MAXLENGTH=10></P> <P><STRONG>Product Name:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"part_name\" SIZE=50 MAXLENGTH=100></P> <P><STRONG>Set of: </STRONG> <INPUT TYPE=\"text\" NAME=\"peices\" SIZE=6 MAXLENGTH=10></P> <P><STRONG>Product Description:</STRONG> (if entered, this will be displayed on the product page)<BR> <TEXTAREA NAME=\"part_desc\" COLS=50 ROWS=5 WRAP=virtual></textarea></P> <P><STRONG>Finish:</STRONG><BR> <select name=\"finish\" id=\"finish\"> <option value=\"aged\" selected>aged</option> <option value=\"bamboo\">bamboo</option> <option value=\"blp\">BLP</option> <option value=\"cham\">cham</option> <option value=\"fountain\">fountain</option> <option value=\"glazed\">glazed</option> <option value=\"metal\">metal</option> <option value=\"rustic\">rustic</option> <option value=\"rv\">RV</option> <option value=\"sand finish\">sand finish</option> <option value=\"sandstone\">sandstone</option> <option value=\"test\">test</option> <option value=\"toadstools\">toadstools</option> </select> </P> <P><STRONG>Color:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"color\" SIZE=35 MAXLENGTH=100></P> <STRONG>NOTE:</STRONG><em> All dimensions are in inches. Please type in numbers only.</em><br><br> <fieldset><STRONG>Size 1 Name: </STRONG>(ex: large, small)<BR> <INPUT TYPE=\"text\" NAME=\"size1name\" SIZE=10 MAXLENGTH=25> <P><STRONG>Width:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"width\" SIZE=8 MAXLENGTH=8></P> <P><STRONG>Height:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"height\" SIZE=8 MAXLENGTH=8></P></fieldset> <P><fieldset><STRONG>Size 2 Name:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"size2name\" SIZE=10 MAXLENGTH=25></P> <P><STRONG>Width:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"width2\" SIZE=8 MAXLENGTH=8></P> <P><STRONG>Height:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"height2\" SIZE=8 MAXLENGTH=8></P></fieldset> <P><fieldset><STRONG>Size 3 Name:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"size3name\" SIZE=10 MAXLENGTH=25></P> <P><STRONG>Width:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"width3\" SIZE=10 MAXLENGTH=25></P> <P><STRONG>Height:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"height3\" SIZE=10 MAXLENGTH=25></P></fieldset> <P><fieldset><STRONG>Size 4 Name:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"size4name\" SIZE=10 MAXLENGTH=25></P> <P><STRONG>Width:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"width4\" SIZE=10 MAXLENGTH=25></P> <P><STRONG>Height:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"height4\" SIZE=10 MAXLENGTH=25></P></fieldset> <P><fieldset><STRONG>Size 5 Name:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"size5name\" SIZE=10 MAXLENGTH=25></P> <P><STRONG>Width:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"width5\" SIZE=10 MAXLENGTH=25></P> <P><STRONG>Height:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"height5\" SIZE=10 MAXLENGTH=25></P></fieldset> <P><em>Product Availibilty:</em></P> <P><STRONG>Current Ammount in Stock:</STRONG><BR> <INPUT TYPE=\"int\" NAME=\"in_stock\" SIZE=10 MAXLENGTH=10></P> <P><STRONG>Current Ammount on Order:</STRONG><BR> <INPUT TYPE=\"int\" NAME=\"on_order\" SIZE=10 MAXLENGTH=10></P> <P><em>Product Pricing:</em></P> <P><STRONG>Wholesale Price:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"whole_price\" SIZE=10 MAXLENGTH=10></P> <P><STRONG>Retail Price:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"ret_price\" SIZE=10 MAXLENGTH=10></P> <input type='hidden' name='submitted' value='TRUE' id='<?=time();?>' > <input type='hidden' name='MAX_FILE_SIZE' value='<?=$max_file_size;?>' > <? for($x=0;$x<$num_of_uploads;$x++){ $form .= \"<input type='file' name='file[]'><br />\"; } $form .= \"<br /> <font color='red'>*</font>Maximum file length (minus extension) is 15 characters. Anything over that will be cut to only 15 characters. Valid file type(s): \"; for($x=0;$x<count($file_types_array);$x++){ if($x<count($file_types_array)-1){ $form .= $file_types_array[$x].\", \"; }else{ $form .= $file_types_array[$x].\".\"; } } echo($form); if(isset($_POST[\"submitted\"])){ THIS IS LINE 133 -- THIS IS LINE 133 -- THIS IS LINE 133 -- uploaderFILES($num_of_uploads, $file_types_array, $max_file_size, $upload_dir); } ?> <!-- Cancel for now <P><STRONG>Picture Link:</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"pic_loc\" SIZE=75 MAXLENGTH=100></P> <P><STRONG>Extra Picture Link 1 (if applicable):</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"pic_loc2\" SIZE=75 MAXLENGTH=100></P> <P><STRONG>Extra Picture Link 2 (if applicable):</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"pic_loc3\" SIZE=75 MAXLENGTH=100></P> <P><STRONG>Extra Picture Link 3 (if applicable):</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"pic_loc4\" SIZE=75 MAXLENGTH=100></P> <P><STRONG>Extra Picture Link 4 (if applicable):</STRONG><BR> <INPUT TYPE=\"text\" NAME=\"pic_loc5\" SIZE=75 MAXLENGTH=100></P> --> <P><INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Enter Item Into Inventory\"></P> </FORM> <P><a href=\"cntrconmgrgrbw.php\">Go Back to Main Menu</a></P>"; } I appreciate any help in advance. PLEASE SAVE ME FROM MY OWN CODE! -Mark
×
×
  • 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.