Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. You ned to check to see if $beer->brewery->logo_url is empty then display your default image. If its not then display the supplied brewery logo. Example code $logo_image = empty($beer->brewery->logo_url) ? 'default-brewer-logo.png' // use this default image if brewery->logo_url is empty : $beer->brewery->logo_url; // use the brewery logo from json if it is not empty ... echo '<article class="beer-entry"> <div class="beer-image"><img src="'.$logo_image.'" /></div>
  2. Im guessing the makePyramid() function is supposed to add the deck of cards to the $pyramid array? And display2Darray() function outputs the pyramid? Passing the variable to a function only sends its value to the function. It wont change the contents of the variable. Your display2Darray() function will be trying to get contents from an empty array. This is will be the cause of the undefined offset In order for you code to work as intended you can either pass $pyramid by reference function makePyramid(&$array, $size, $deck) Or the alternative is for the makePyramid() function to return the new array structure ($array) once it has dealt the cards. function makePyramid($array, $size, $deck) { ... return $array; } $pyramid = makePyramid($pyramid, $size, $deck); Please read the functioins documentation here - http://php.net/manual/en/language.functions.php
  3. $_SESSION['cart_array'] contains an array of items. Each item has their own sub array. The sub array contains the item_id a value $_SESSION['cart_array'][21] will return the item in the cart_array that has the numerical key of 21. This will not return the sub array with the item_id value of 21 To get rid of the item with the item_id of 21 you need to use numerical index 0. unset($_SESSION['cart_array'][0]); You should restructure your $_SESSION['cart_array'] so your item ids are used as the keys for each item in the array and used as a value in the sub array
  4. Your code is using short tags <? or <?= These tags are only available if a setting called short_tags is enabled in the php.ini. On your server they appear to not be enabled because you are seeing the PHP code in your webpage where the textbox should be. I would advise you change the short tags to their full counterparts as shown below <? should be <?php <?= should be <?php echo Also could you wrap your code in tags or click the <> button in the editor when posting code.
  5. Most likely because the second item in the $stock array does not contain a sims array. You to check to see if $stock['sims'] is an array before looping through it with foreach foreach ($stock["stock"] as $stock) { // check to see if there is a sims array for this item if(is_array($stock['sims'])) { foreach ($stock["sims"] as $sim) { echo $sim . "</br>"; } } }
  6. To be honest I would advise you to not use that script at all. The last official release was 5 years ago. There are alot of known vulnerabilities for that script which will allow an attacker to easily hack your site, that is reason alone not to use this script. I would advise you to either find a replacement script or to pay a developer to create the site for you. We are not going to go through an abandoned project and fix it for you.
  7. You say you are including that script in your site? Does your site code also use a variable called $title? I think the code for your site is conflicting with that portion of code you have posted. If the script your are including is a standalone file then change all instances of $title used in that script to a different name, ie $atom_title
  8. Oh.... MightBeforeGod has modified the original code for the login() function. I was looking at the code from the tutorial.
  9. See step 8 of 8 to see how to protect your pages using the code form that tutorial. Also the following lines in process_login.php (specifically the header() line) is not quite right. $page = login($email, $password, $mysqli); if ($page == true) { // Login success header('Location: '. $page); In the header you are redirecting to $page. But hang on $page contains a boolean value (true or false) as that is what the login() function returns, true if the user successfully authenticates and false if they don't. You need to specify the actual url for where you want to redirect the user to, example for redirecting to profile.php page header('location: profile.php');
  10. The query is mos likely failing for some reason. Add the following $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // force pdo to throw an exception id an error occurs. After $conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
  11. Then you will need to look at your servers error logs
  12. One lines 4, 5, 6 and 7 you define variables but never use them? On lines 9 through to 12 you need to use the concatenation assignment operator .= not the assignment operator = Otherwise only the Requirement line will send in the email body. Line 13. Not sure what you are doing there. Could you tell use how you are testing this code? Are you sure PHP has been configured to use a mail server?
  13. Check your severs error logs to see why you are getting that error. Or add the following after the opening PHP tag line to see the error message(s) in the browser. ini_set('display_errors', 1); error_reporting(E_ALL);
  14. mysql_real_escape_string() should only be used on string values (hence the word string in its name) . If you are inserting a number into the database then at least check that is a number first (using ctype_digit or filter_var with the appropriate filter flag) before using it in your query. Also do not use mysql_ functions as they are deprecated meaning they are no longer supported and could be removed from future versions of PHP. You need to update your code to use PDO or MySQLi and use prepared statements when using user input in your queries.
  15. You dont need to escape the spaces in the file path. PHP will treat the \ as a directory separator.
  16. After this if(isset($_POST['empId']) && isset($_POST['name']) && isset($_POST['date']) && isset($_POST['basicSalary']) && isset($_POST['leave']) && isset($_POST['salaryPerDay']) && isset($_POST['leaveDeduct']) && isset($_POST['netSalary'])) { Add the following. It will show what was submitted to page printf('<pre>%s</pre>', print_r($_POST, 1)); Are the correct values shown for all inputs? If they are all correct. Then you need to debug your payrollData() function. Can you post the code for that?
  17. You can get the form with the class of ajax using getElementsByClassName. Once you have the the form you can iterate over the form elements and get the name and value attributes using form.element.name or form.element.value Live Example
  18. You can not use an id for the update button as ids can only be used once. As you have multiple update buttons you should use a class class="updatebtn" and use .updatebtn as the selector Now to get the id value from the update button that was clicked you need to pass this to the selector to get the attribute value for the button that was clicked. var id = $(this).attr('value'); As you are using the product id for associating the update button with the item. You can do the same with the dropdown menu by naming it using this <select name="quantity['.$id.']"> Now in your Jquery code you can use the following to get the quantity for the item var quantity_selected = $('select[name="quantity['+id+']"] option:selected').attr('value'); // for debug purposes show quantity for product id being updated alert('The quantity for item id '+id+' is being updated to '+quantity_selected); You can see Live demo here for the JQuery code.
  19. The only time you need to specify the hostname as a domain name is if your are connecting to it remotely. In most cases setting it localhost will be just fine.
  20. The appearance of a web page has nothing to do with PHP, it is used to generate the content for the page. A webpage is constructed with HTML and styled using CSS. Also please adjust your signature, It is against our Rules & ToS.
  21. Nor do we without seeing your code. It also helps if you posted your question in the correct forum section. PHPFreaks.com Questions, Comments, & Suggestions forum for is for posting questions/problems about our forum/site.
  22. Have you tried this your self? If you are not familiar with a switch then see here first Basically you pass e.keyCode as the expression. 65 and 68 will be used as the case expression. The if statements will go in the corresponding case statement.
  23. The problem is you are not making sense of what we are telling you. Psycho already told you what you need to do here
  24. That seems a logical step to do. Otherwise all the links on your local wordpress installation will be pointing to your live site and not your local installation. However a blank page for a PHP script usually means an unrecoverable error was encountered. To see what the error is you need to either look at your servers error log or enable PHP error reporting.
  25. That line of code needs to go inside the foreach loop. But you do not want to use the $nr_row for the condtion. Instead you need to create a counter. To do so add $i = 0; before the foreach loop then in place of $nr_row you'd use ++$i This will increment $i by one on very iteration of loop. That line of code will now toggle between linksmen and linksmen_s classes on every iteration.
×
×
  • 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.