Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Looking at the pear project page for MDB2 it is no longer being maintained and is not compatible with the latest versions of PHP5. If your project requires this library then you need to downgrade PHP to an earlier version or upgrade your PHP app to use a different database api such as PDO, or MySQLi
  2. Before you can select a database with mysql_select_db you need to connect to mysql first.
  3. On your site what image carousel are you referring to? The only carousel I see is Shop By Brand and all images appear to be loading.
  4. Turn error reporting on, by adding these line at the top the page error_reporting(E_ALL); ini_set('display_errors', 1); or check your sever's error log.
  5. with mod_rewite module.
  6. You need to change the time_reset() function so it gets the record that matches the users username to get their rest_timer value. As it stands now it is always getting the first record.
  7. Its a bit outdated. It use PHP5.2.6 which was released 5 years ago! PHP latests releases are 5.4 and 5.5 I recommend updating your AMP stack as soon as possible to more recent versions, to something like WAMP or XAMPP. Or better yet install the AMP stack manually yourself.
  8. Because this DB::select('accounts'); $timer = DB::fetch_row(); Is first getting all the accounts from the accounts table. Then on the next line it gets the first result from the table which will always be the first record in the table. You need to change your query so it only gets the record for the user you are renewing the membership to. Also if you used a date time field mysql can update the reset_timer field using one query like this UPDATE accounts SET reset_timer=DATE_ADD(CURDATE(), INTERVAL 1 MONTH) WHERE id=$user_id
  9. What you need to do is, during the checkout process go through each product stored in the basket and work out whether the product is in the accessories, scarves and jewelr categeories. Then work out the cost of the order and check to see if the passes the minimum order limits. Pseudo code would be $accessories_min_order = 150; $otheritems_min_order = 500; $accessories_order = 0; $otheritems_order = 0; foreach($item_in_basket as $item) { $sub_total = $item->price * $item->quantity; // work out item price if($item in accessories, scarves or jewelr catergory) // find out what category the item is in { $accessories_order += $sub_total; // running total for accessories } else { $otheritems_order += $sub_total; // running total for other items } } // check if accessories meets minimum order limit if($accessories_order > 0 && $accessories_order < $accessories_min_order) { accessories did not meet minimum order } // check if other items passes minimum order limit if($otheritems_order > 0 && $otheritems_order < $otheritems_min_order) { other items did not meet minimum order } process order
  10. Yea, that would be more sensible.
  11. Change your .htaccess rewriteRule to RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ([a-z0-9_\.-]+)/? userprofile.php?username=$1 [L,NC] Then in userprofile.php add printf('<pre>%s</pre>', print_r($_GET, true)); To make sure the $_GET['username'] is being set correctly
  12. Add a ; after '$pic' below echo "picsarray[$key] = '$pic';"; ^ add this This could be causing a JavaScript error, which then prevents the dropdown menu from displaying.
  13. Sounds to me PHP is not connecting to MySQL correctly. Or your server is not setup quite right. Where are you running this code?
  14. Sort the picsarray in the javascript using picsarray.reverse(); Or sort the pictures first in PHP before generating the JavaScript picsarray function returnimages($dirname=".") { $pattern="~\.(jpe?g|gif)$~"; $files = array(); if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(preg_match($pattern, $file)){ $files[] = $file; } } closedir($handle); } // sort pics in reverse order rsort($files); // output images into javascript array foreach($files as $key => $pic) { echo "picsarray[$key] = '$pic'"; } }
  15. For this to work Company Name: <input type=text name=cname size=50 maxlength=50> <p> <input type=submit> You need to wrap it within a <form> tag <form action="" method="post"> Company Name: <input type=text name=cname size=50 maxlength=50> <p> <input type=submit> </form> You then get the value from the Company Name text field using $_POST['cname']
  16. No. As there are characters other than quotes that can cause SQL injection, which mysql_real_escape_strings also escapes. In what way did it not work for you? The code I posted is the correct usage for that function.
  17. You need to set the values when the form has been submitted <td><input type="text" name="username" value="<?php echo isset($_POST['username']) ? $_POST['username'] : ''; ?>"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="<?php echo isset($_POST['password']) ? $_POST['password'] : ''; ?>"></td>
  18. You applied mysql_real_escape_string to the query. This function should be used on values to be used within the query. This $name = $_POST['dgt']; if(strlen($name) != "10") { print "Name is incorrect."; } else { $query = mysql_query("SELECT * FROM contacts WHERE name ='$name';"); $fix = mysql_real_escape_string($query); Should be $name = mysql_real_escape_string($_POST['dgt']); // Apply mysql_real_escape_string to this value. So it safe to use in the query later if(strlen($name) != "10") { print "Name is incorrect."; } else { $query = mysql_query("SELECT * FROM contacts WHERE name ='$name'");
  19. You use the concatenation operator to combine them together. echo "<pre><i>Company Department:</i> ".$company->name .' '. $company->department."<br/>";echo"</pre>"; array_merge is for merging arrays together, not strings. I guess you are in the same class as JonnyPHP or the same person.
  20. The solution is to use a site wide stylesheet which sets the text color to white for all html elements. Create a new file called style.css, and add the following to it html { background-color: #000; /* Set page background to black */ color: #FFF; /* Set page text color to white */ } Now in any page you want to set the page black, with white text you'd link to that stylesheet using <link rel="stylesheet" href="style.css" />
  21. Yes add \. into the square brackets RewriteRule ^([-a-zA-Z0-9_\.]+)$ userprofile.php?username=$1
  22. Change your echo's to store the strings into an array, Use shuffle to randomize their order, then use implode to echo the new order Code for displayProfile function function displayProfile($memberClass) { echo "<div class='memberProfile'><p>"; # spit out the image of our character # <img src="images/spiderman.jpg" /><br /> echo "<img src=\"".$memberClass->imagePath."\" width=200px /><br />"; # spit out our caption $lines = array(); $lines[] = "This is ".$memberClass->name; //counts the "+" for the power level $lines[] = "He has a power level of ".strlen($memberClass->powerlevel); $lines[] = "He resides in ".$memberClass->location; $lines[] = "He was first published in ".displayBirthdate($memberClass->published); $lines[] = "Making him ".calculateAge($memberClass->published)." years old!"; //wraps the string after the specified # of characters $lines[] = "His superpower is ".wordwrap($memberClass->superpower,35); $lines[] = "And in that time he's kicked the asses of ".$memberClass->asseskicked." people!"; //finds the average & wraps the string after the specified # of characters $lines[] = "They normally capture their respective enemy ".average($memberClass->personscaught)." times a year."; $lines[] = "You can reach them at <a href=\"#\"> ".$memberClass->email."</a>"; shuffle($lines); // randomize the order of the lines above echo implode("<br />\n", $lines) . "</p></div>"; // output the randomized order }
  23. If you use Denno's code above make sure to call session_start for the sessions to work
  24. The bit in bold is heredoc syntax. You don't replace it with anything. I tend to use heredoc for echoing large amounts of HTML, saves having to escape quotes This is the code I used for testing <?php $dbh = new PDO('mysql:dbname=test;host=127.0.0.1', 'user', 'pass'); try { if(isset($_POST['update'])) { $updatedQuery = "UPDATE fac_detail SET first_name=:fname, last_name=:lname, height=:height, cap=:cap,colors=:color WHERE employee_id=:id"; $stmt = $dbh->prepare($updatedQuery); // loop over each record in $_POST['record'] // getting the employee_id and each fields value foreach($_POST['record'] as $employee_id => $field) { $stmt->bindParam(':fname', $field['firstName'], PDO::PARAM_STR); $stmt->bindParam(':lname', $field['lastName'], PDO::PARAM_STR); $stmt->bindParam(':height', $field['height'], PDO::PARAM_STR); $stmt->bindParam(':cap', $field['cap'], PDO::PARAM_STR); $stmt->bindParam(':color', $field['color'], PDO::PARAM_STR); $stmt->bindParam(':id', $employee_id, PDO::PARAM_INT); $stmt->execute(); } } $sql = "SELECT * FROM fac_detail"; $stmt = $dbh->prepare($sql); $stmt->execute(); $arrValues = $stmt->fetchAll(PDO::FETCH_ASSOC); $row = $stmt->fetch(); } catch(PDOException $e) { die($e->getMessage()); } echo <<<HTML <form method= post> <table id="recordTable"> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Height</th> <th>Cap</th> <th>Color</th> <th>Editable BUTONNNS</th> </tr> </thead> <tbody> HTML; foreach ($arrValues as $row) { $id = $row['employee_id']; echo <<<FORM_FIELDS <tr> <td><input type="text" name="record[$id][firstName]" value="{$row['first_name']}" /></td> <td><input type="text" name="record[$id][lastName]" value="{$row['last_name']}" /></td> <td><input type="text" name="record[$id][height]" value="{$row['height']}" /></td> <td><input type="text" name="record[$id][cap]" value="{$row['cap']}" /></ d> <td><input type="text" name="record[$id][color]" value="{$row['colors']}" /></td> <td><input type="submit" name="update" value="Update" /></td> </tr> FORM_FIELDS; } echo <<<HTML </tbody> </table> </form> HTML; ?>
  25. Can you explain what it is you are trying to do, as I do not understand.
×
×
  • 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.