Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. echo "<table width=\"612\" height=\"33\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <!--DWLayoutTable--> <tr> <td height=\"33\" valign=\"top\" class=\"table_bottom\">".$alliance['clan']."</td> <td valign=\"top\" class=\"table_bottom\"><a href=\"report.php?accept=".$alliance['inviteid']."\">accept</a></td> <td valign=\"top\" class=\"table_bottom\"><a align=\"right\"><a href=\"report.php?decline=".$alliance['inviteid']."\">decline</a></td> </tr> </table>";
  2. function drawGame($rows = 10, $cols = 10, $tileWidth = 50, $tileHeight = 50) { $gameWidth = $tileWidth * $cols; $gameHeight = $tileHeight * $rows; $game = "<table frame=\"border\" width=\"$gameWidth\" height=\"$gameHeight\" cellpadding=\"0\" cellspacing=\"0\">"; for ($i = 0; $i < $rows; ++$i) { $game .= '<tr>'; for ($j = 0; $j < $cols; ++$j) { $game .= "<td width=\"$tileWidth\" height=\"$tileHeight\"><img src=\"tile.gif\" alt=\"tile\"></td>"; } $game .= '</tr>'; } print $game . '</table>'; }
  3. if($level > "owner"){ is the same as if ($level > 0){ What does $level contain? If $level contains a string (altough not entirely sure it's possible php performs an internal strcmp() but then again you'll get unexpected results as member > owner thus member may ban other members) you'll get if (0 > 0) { if(!$ban){ }else{ is the same as if ($ban){
  4. $query = mysql_query("SELECT id FROM users WHERE username='$cookieuser'") or die(mysql_error()); list($authorid) = mysql_fetch_array($query, MYSQL_NUM);
  5. SELECT now() - orgDateAmended AS x FROM table
  6. <td width="284"><input name="imageField" type="image" src="file:///Dreamweaver%20MX%20TFS/DWMX_project/Lesson_11_Forms/Images/spacer.gif" width="110" height="1" border="0"></td> <td width="2"><input name="imageField2" type="image" src="file:///Dreamweaver%20MX%20TFS/DWMX_project/Lesson_11_Forms/Images/spacer.gif" width="1" height="1" border="0"></td> <td width="463"><input name="imageField3" type="image" src="file:///Dreamweaver%20MX%20TFS/DWMX_project/Lesson_11_Forms/Images/spacer.gif" width="463" height="1" border="0"></td> should be: <td width="284"><input name="imageField" type="image" src="Images/spacer.gif" width="110" height="1" border="0"></td> <td width="2"><input name="imageField2" type="image" src="Images/spacer.gif" width="1" height="1" border="0"></td> <td width="463"><input name="imageField3" type="image" src="Images/spacer.gif" width="463" height="1" border="0"></td> Don't forget to upload the Images directory and make sure this html file is in the same directory as the images directory Second you need to define a From: header otherwise your e-mail will end up as SPAM $phpversion = phpversion(); if (mail( "Marnav14@earthlink.net", 'Contact Us Form', "Name: $name\r\n email: $email\r\n Tel: $tel\r\n question: $question", "From: $name <$email>\r\nReply-To: $name <$email>\r\nX-Mailer: PHP/$phpversion")) { header( "Location: http://www.myninelives.com/thank.html" ); }
  7. if (!move_uploaded_file($_FILES['photo']['tmp_name'], $target))
  8. exit() and die() are considered bad practices because at no point should your application output technical information about your system to the end-user. Another reason you should at no point display technical information is because hackers will use this information to gain control over your application/server.
  9. Creating a footer is simple you can do it using plain text and prepend a dashed line of 70 characters or using an html e-mail in which I suggest using a table all styles come inline. <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="..">..</td> </tr> </tbody> <tfoot> <tr> <td style="..">..</td> </tr> </tfoot> </table>
  10. http://www.mightystuff.net/php_thumbnail_script
  11. CREATE TABLE models ( models_id INTEGER NOT NULL AUTO_INCREMENT ); CREATE TABLE colours ( colours_id SMALLINT NOT NULL AUTO_INCREMENT ); CREATE TABLE models_colours ( models_colours_models_id INTEGER NOT NULL, models_colours_colours_id SMALLINT NOT NULL, PRIMARY KEY (models_colours_models_id, models_colours_colours_id) ); INSERT INTO models_colours VALUES (1, 1), # model A has color red (1, 2), # model A has color green (1, 3), # model A has color blue (2, 3), # model B has color blue (2, 4), # model B has color yellow (2, 5); # model B has color purple SELECT * FROM colours JOIN models_colours ON colours_id = models_colours_colours_id WHERE models_colours_models_id = 1 # returns red, green and blue
  12. Consider you are a layman visiting a website. You click on some links and suddenly this pops up: You - the layman - are surprised and wondering what your next step should be all it says is something he doesn't even understand? He thinks maybe I should check out the competition and buy my stuff there as they tend to refer him to a nice 404 page with a clear message what happened and steps he can take from that point on. Instead use a combination of set_error_handler() and trigger_error() (.. or trigger_error('..') if you like). This will allow you to handle the error (log it to a db or something) and refer the user to a (static) page that give him some advice on what happened and what he can do next? (search, ..) The advantage between exception handling and the use of exit() (or die()) is that when you call the latter the execution of your script ends abruptly (the message you enclose within it and any output in the buffer is send to the browser and possibly breaks your page) leaving you no options to handle it properly.
  13. //This function separates the extension from the rest of the file name and returns it $ext = pathinfo($filename, PATHINFO_EXTENSION); //This applies the function to our file $ext = findexts ($_FILES['uploaded']['name']) ; should be: //This function separates the extension from the rest of the file name and returns it $ext = pathinfo($_FILES['uploaded']['name'], PATHINFO_EXTENSION);
  14. $name is the name of the category and $children are the children of the parent category presumably they afterwards create another foreach loop going over the children categories.
  15. function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } is the same as: $ext = pathinfo($filename, PATHINFO_EXTENSION); it's not $target . basename($_FILES[..]) but: $target = $target . $ran2 . $ext; mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$ran2.$ext')") ; $ran2.$ext is wrong because it will insert filename..extension P.S. $pic=($_FILES['photo']['name']); $pic is never used
  16. if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); } This code creates an array for every top-level category (every record in your database that a 0 as a parent_id). Which will give you something like: Cat 1 Cat 2 Cat 3 else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); } This code retrieves the earlier set $id (== $parentId) and fills the 'children' => array() part with the $id and name of the child categories. Which will give you something like: Cat 1 Cat 1.1 Cat 1.2 Cat 1.3 Cat 2 .. But it is also possible that a child becomes a parent like: Cat 1 (parent of 1.1 and ancestor of 1.1.1) Cat 1.1 (child of 1) Cat 1.1.1 (child of 1.1 and descendant of 1)
  17. How is it that your code can be double as fast as you do the same thing I did you have both: SELECT * FROM games and ORDER BY rand() LIMIT 3 plus you throw in a join with a subquery SELECT max(..) which means it will go over each row until it has found the key with the highest value. IMO this code does the opposit of what you claim.
  18. if (!isset($_SESSION['video_viewed']) ^ $_SESSION['video_viewed'] !== $vid_id) { $_SESSION['video_viewed'] = $vid_id; mysql_query("UPDATE my_vid SET v_hits = v_hits + 1 WHERE v_id = $vid_id"); } $result = mysql_query("SELECT * FROM my_vid WHERE v_id =$vid_id"); echo "<table border='0' width='50%' align='center'> <tr valign=top> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr valign=top>"; // echo "<td>" . $row['v_name'] . "</td>"; echo "<br>"; echo "<td align='center' style='font:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; text-transform:uppercase;'>" . $row['v_name'] . "</td>"; echo "</tr>"; echo "<tr valign=top>"; echo "<td align='center' style='font:Arial, Helvetica, sans-serif; font-size:14px; color:#006699'>" . $row['v_des'] . "</td>"; echo "</tr>"; echo "<tr valign=top>"; echo "<td>" . $row['v_emb'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con);
  19. You should have a field something similar like below in your table: CREATE TABLE videos ( videos_times_viewed INTEGER, ); When a user views a video update the table: UPDATE videos SET videos_times_viewed = videos_times_viewed + 1 WHERE videos_id = $id
  20. Try: SELECT * FROM games ORDER BY rand() LIMIT 3
  21. Try: print "<option value=\"".$rs_skill["id"]."\"".(isset($_POST['skill']) && in_array($rs_skill['id'], $_POST['skill']) ? ' selected="selected"' : '').">".ucwords($rs_skill["skill"])."</option>";
×
×
  • 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.