-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
you would be looking to make some changes in and around here: for($i=1; $i<=4; $i++) { $fields[$i] = 'name'.$i; $values[$i] = mysql_real_escape_string(basename(trim($_FILES[$fields[$i]]['name']))); if($values[$i] != '') { $updateVals[] = "{$fields[$i]} = '{$values[$i]}'"; } } but if you don't have a clue what the code is doing I'm going to have say that you need to learn before you start editing it. Check the php manual site for $_FILES() and associated information. p.s. could you please use or [ code ] [/code ] BBtags when posting actual code as it makes it much easier to read.
-
try here: $fileName = $file['name']; $fileName .= "_" . strtolower(substr(md5(time()), 0, 4)); $tmpName = $file['tmp_name']; $fileSize = $file['size']; $fileType = $file['type'];
-
ok, your or die should be on the mysql_query() line, not the one that builds your SQL statement. if you could also output the SQL query in the or die that would help too: $numresults = mysql_query($numresultsSQL) or die (mysql_error()."<br><br>Encountered when atemptempting to run the following query:<br>$numresultsSQL"); Let me know what comes back from that.
-
yeah, I missed out the function brackets for time() in that last one there. I just ran the following code: <?php $filename = "myfile"; $filename .= "_" . strtolower(substr(md5(time()), 0, 4)); $filename .= ".jpg"; echo $filename; ?> and got as a result : let me know if that helps
-
AJAX return to JS variable - Undefined
Muddy_Funster replied to Muddy_Funster's topic in Javascript Help
Right, I can't get my head round this at all. I've got me a book on JS, if this shits going to be ruining my happyness then I'm at least going to know how its doing it. -
lets see your updated code please.
-
your using mysql_real_escape_string() properly already. mas for a timestamp, It's been a while but I'm sure it's just something like : $filename .= time(); although you would need to do that before you add the extension obviously... What I found easier to manage (and I suppose more secure as well) was to use a substring of a md5 encrytipted time : $filename .= "_" . strtolower(substr(md5(time)), 0, 4)); I found it more manageable for generating unique codes for delivery notes.
-
extend variable from one function to another
Muddy_Funster replied to Zerpex's topic in PHP Coding Help
put return $newname; before your closing } for your function. -
I wouldn't rely on a form for this, just pass two individual arrays and put them into a multi dimensional array on the php page at the end.
-
now that I actualy have a close look at the code I see you have one loop in there already, a while loop. Unfortunately, you have chosen to perform 3 additional queries within this loop - very bad idea! This will hammer you db server as the table grows. fist up we need to condense all those queries into one: $sql = <<<SQL_BLOCK SELECT product_option_value_description.product_id, product_option_value_description.name, product.image, product_option_value.product_option_id, product_option_value.product_option_value_id FROM product_option_value_description LEFT JOIN product ON (product_option_value_description.product_id = product.product_id) LEFT JOIN product_option_value ON (product_option_value_description.product_id = product_order_value.product_id) WHERE product_option_value_description.name LIKE '%$partialNumber%' SQL_BLOCK; should do the trick. next you want to move your output inside the while loop that you have for the data retreval: $result= mysql_query($sql) or die(mysql_error()); $display=''; while ($row = mysql_fetch_array($result){ $display .= <<<HTML_BLOCK <div> <br /><br /> Key Number: {$row['name']}</a> <form action="http://www.co.uk/teststore/index.php?route=checkout/cart" method="post" enctype="multipart/form-data" id="product"> <br /> <table style="width: 100%;"> <tr> <td> Colour: <select name="option {$row['product_option_id']}"> <option value="{$row['product_option_value_id']}"></option> </select></td> </tr> </table> <div class="content"> Qty: <input type="text" name="quantity" size="3" value="1" /> <input type="hidden" name="product_id" value="$row['product_id'];" /> <input name="submit" type="submit" value="Add to Cart" /> </div> </form> {$row['product_option_value_id']} </div> <br /> <img height="150" width="150" src='http://www.co.uk/teststore/image/{$row['0']}> HTML_BLOCK; echo $display that should at least be close enough for you to get the idea. Another thing, you'll need to get out the habbit of using short open tags (<? ) - they are depreciated.
-
yeah, your php is a bit of a mess: you seem to be doing everything twice: you have an elseif checking the same condition as the first if (not sure if you expect things to change from one line to the next, but they won't in this case) and then you nest your while loop for disply inside....well....a while loop for display, which is re-assigning different values to the same variables. I'm curious, cold you post a screen cap of what your actual output page looks like?
-
your getting all the info back, your just not looping through the result set when your using the info, your oly using the first entry returned, not all of them, the info is there, you just need some loops to access it properly.
-
Selecting id and order from list of votes.
Muddy_Funster replied to starvinmarvin14's topic in MySQL Help
lets tidy this up a little: $statement = "votes LEFT JOIN rants ON votes.rantid = rants.id WHERE vote = 'up' GROUP by rantid ORDER BY nrRatings DESC"; $query = mysql_query("SELECT votes.*, rants.*, COUNT(votes.*) AS nrRatings, DATE_FORMAT(rants.date, '%M %e, %Y, %l:%i%p') as newdate FROM {$statement} LIMIT {$startpoint} , {$limit}"); turns into: $sql = <<<SQL_BLOCK SELECT votes.*, rants.*, COUNT(votes.*) AS nrRatings, DATE_FORMAT(rants.date, '%M %e, %Y, %l:%i%p') as newdate FROM votes LEFT JOIN rants ON votes.rantid = rants.id WHERE vote = 'up' GROUP by rantid ORDER BY nrRatings DESC LIMIT $startpoint , $limit"; SQL_BLOCK; $query = mysql_query($sql) or die(mysql_error()."<br><br>Returned by Server when atempting to run the following query:<br>$sql"); not the use of the or die to capture the SQL error and return it to the screen. Also note I havn't actualy changed any of your SQL, only formated things a little differently so that when the error comes back you can see the SQL statement that was sent to the server as it was at that point. -
but I formated the date for them too, i just forgot the _ in the middle of DATE_FORMAT() was all
-
never used that class lib, sorry
-
make this change: $query = "SELECT picture_number, first_name, middle_name, first_family_name, second_family_name, DATEFORMAT(birthdate, '%e-%c-%Y') as birthdate, gender FROM child_info ORDER BY picture_number ASC";
-
to call a php function you generaly use functionName(variableValue), which is exactly what you are doing here: $capital = $capitals($capitalsinteger); let me illustrate with this code: <?php $anynameyoulike = "MyFunction"; function MyFunction($start, $finish){ $number = rand($start,$finish); return $number; } $anyOtherName = MyFunction(1,5); $aThirdName = $anynameyoulike(20,27); echo "$anyOtherName<br><br><br>$aThirdName"; ?> the key lines are the two just above the echo line. see how both MyFunction and $anynameyoulike can both be used to call the function? So your code has PHP looking up what $capitals contains and then trying to find a function with the name that matches the string content of the variable (which we all know it can't do). You need to totaly redesign your code.
-
everything you open needs to be closed....everything. some browsers are more tollerent of unclosed tags than others.... in html5 and xhtml hr is a self closing tag, as in <hr calss='red' /> I'm not sure about html 4.x I'm just not sure why you are using a rigid <hr/> when you have divs flying about the place already. also, as far as the validator goes, it's best practice to conform to the w3c standard, but if you don't it doesn't meed that your page won't work.
-
move it to the top of the page?
-
You likely need to authenticate with the SMTP server in order to send the mails, unless you are using linux then php mail() and sendmail() won't pass SMTP authentication information. you would need to use something else (or set up a linux VM) that said your hosted site should be linux and as such if you set the authentication settings in that it should work.