Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Either do what mac_gyver suggested, by converting your php distance function to a stored procedure in SQL. Or grab all the results from the database and run each user's latitude and longitude through your distance function separately. You cannot call PHP functions within SQL queries.
  2. Oh I see now. For the modal to work you need the form to be submitted by ajax and then output the form in the modal. Currently your page is just static, no data is being sent/received from your script to be able to edit the event. All you are doing is displaying the modal when the edit-event button is pressed.
  3. Here if($_SESSION['user_id'] == $row['creatoruserid']) { echo " <form action='".$_SERVER['PHP_SELF']."' method='post'> <input type='hidden' name='event_id' value='".$row['event_id']."' /> <ul class='profile-user-buttons'> <li> <button name='edit_event' class='edit-event medium-button-grey'>Muokkaa tapahtuma </button> </li> <li><button type='submit' name='remove_event' class='remove-event medium-button-grey'>Poista tapahtuma</button> </li>"; You have an edit event button (7th line). So you're passing the event_id to your edit event script via $_POST. When the user clicks the edit_event button you'd use $_POST['event_id'] to get the event out of the database, then in the form you provide for editing the event you need add the event_id as a hidden form field. <input type='hidden' name='event_id' value='".$_POST['event_id']."'/> The code that then updates the event when the update_event button is pressed you'd use $_POST['event_id'] in your query to target the event that is being updated.
  4. $row['t.old_text'] should be $row['old_text']
  5. When you list events what method are you providing so users can edit them? Is it a link, a button?
  6. In the first form you're passing the event_id as a hidden form field. However in the second form the event_id is not present. In both cases you need to be defining the event_id in the form, then in the code that processes the submitted form your'd use $_POST['event_id'] to get the events id To set the form fields with predefined data you need echo the fields value within the value attribute. Example <input type="text" name="event_name" class="full" value="<?php echo $row['event_name']; ?>" placeholder="Tapahtuman nimi" />
  7. You need to create a new table for where the tokens generated by the rememberMe class are stored in your database. The table needs four columns which are credential, token, persistent_token and expires. The credential, token, and persistent_token columns hold sha1 string values. The expires column holds a date/time value. When you initiate the rememberMe storage database class you pass in the following associative array array( 'connection' => YOUR EXISTING PDO DATABASE CONNECTION, 'tableName' => 'TOKENS TABLE NAME', /* DATABASE TABLE COLUMN NAMES */ 'credentialColumn' => 'credential', 'tokenColumn' => 'token', 'persistentTokenColumn' => 'persistent_token', 'expiresColumn' => 'expires' ); To implement the rememberMe class you'll need to look at the example code in the example folder.
  8. Rather than have a switch/case statement. You can just put all usernames/passwords into an array. like $users = array( 'username1' => 'password1', 'username2' => 'password2', // etc... ); Then use the following to proccess the login $is_ajax = $_REQUEST['is_ajax']; if(isset($is_ajax) && $is_ajax) { $username = $_REQUEST['username']; $password = $_REQUEST['password']; // check that the user exists in the $users array // and the password for that user matches the entered password if(isset($users[$username]) && $users[$username] == $password) { $_SESSION['isLoggedIn'] = true; echo ("login-$username"); } } However if you find you're adding more username/password entries then you may want to start looking into using a database.
  9. Sounds like you're calling session_start() multiple times. You only need to call this function once to start the session not each time you need to modify the $_SESSION vars. You can set or reset the $_SESSION variables as many times as you like.
  10. You need to divide the numbers by 100 to move the decimal place by 2. Then you can use number format. $number = 9550; echo number_format($number / 100, 2, '.', ',');
  11. The value of alert() needs to be wrapped in quotes alert("' . {$content} . '");
  12. Where is the variable $type defined?
  13. Just set the $_SESSION['profilepic'] to the new profilepic when the image has been uploaded. $_SESSION['profilepic'] = $newimg_name;
  14. I'm guessing change line 147 header("Location: index.php"); to header("Location: upload.php");
  15. I'm guessing you're testing your PHP code on http://localhost and possibly using windows (vista)? Open the hosts file (located in C:\Windows\System32\drives\etc\hosts) as an Administrator you should find two lines that look like 127.0.0.1 localhost ::1 localhost Add a # in front of the last line. When you rerun your script at localhost the get ip function should return 127.0.0.1 instead of :::1
  16. Are you running PHP version 5.4? To check the php version run echo phpversion(); The code being suggested to use will only work on PHP5.4 and onwards.
  17. That code is fine. The try/catch statments will catch any errors from PDO/Database and display the error. The while loop will populate the $results array with the jokes if the query executed ok. The only time you'll get the Undefined variable: jokes in path/to/jokes.html.php error is if your query is returning no results, because there is no entries in the jokes table or when you physically access that file, ie http://site.com/jokes.html.php. This is because the $jokes array is defined in the file that was including jokes.html.php. The $jokes array is not remembered.
  18. Where did you apply .josh's example code? This is the line that needs to be modified for .josh's example to work $textarray = file($whatfile); So it becomes $textarray = array_filter(array_map('trim', file($whatfile))); // OR you could set the FILE_IGNORE_NEW_LINES and FILE_SKIP_EMPTY_LINES flags for file() $textarray = file($whatfile, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
  19. Is the code from the book you're reading? https://github.com/lisawilliams/phpsols If it is then ignore the include_path setting. You do not need to be modifying it. The problem is a file path issue. Is the classes/Ps2/ folder in the D:\Hosting\myaccount\html\mydirectory? If it is then you need to require the Upload.php class using this (remove the ../ from the file path) require_once('classes/Ps2/Upload.php'); The ../ in file path means go up one directory, If you're requiring the Upload.php file using ../classes/Ps2/Upload.php as the file path then PHP will try to find Upload.php from D:\Hosting\myaccount\html\classes\Ps2 folder. I am guessing that classes/Ps2 is actually in the D:\Hosting\myaccount\html\mydirectory folder?
  20. Couldn't you posted the above 4 posts into one post? But anyway you're using the wrong logical operator in dynamic-form.php <?php $cat=$_REQUEST['cate']; if($cat==1 && $cat==2 && $cat==3 && $cat==4) { require_once('OrderStatus.php'); } elseif ($cat==5 && $cat==6) { require_once('NoVal1.php'); } ?> The && (and operator) should be changed to the || (or operator).
  21. There is no method mysqli::get_result but there is a mysqli::result
  22. So you want to allow the player/user to input the quantities they want to buy or sell for each item? You can change the links to input fields using the following echo "<td><input type=tet name=\"gem[$i][buy]\" value=\"\" maxlength=\"3\" size=\"3\" /></td>"; echo "<input type=tet name=\"gem[$i][sell]\" value=\"\" maxlength=\"3\" size=\"3\" /></td>"; Now in the code that processes the form you'll do something like if(isset($_POST['Submit'])) { if(is_array($_POST['gems'])) { foreach($_POST['gems'] as $gem_id => $amount) { $buy_qty = $amount['buy']; // the quantity to buy $sell_qty = $amount['sell']; // the quantity to sell // your code to process gem order here } } }
  23. Not, sure but you need to get the date from the content attribute so maybe $meta = $dom->getElementsByTagName('meta'); for($i=0; $i<$meta->length; $i++){ $itemprop = $meta->item($i)->getAttribute("itemprop"); if ($itemprop == "datePublished"){ $res['datePublished'] = $meta->item($i)->getAttribute("content"); } } }
  24. The thing I see wrong with that code is only line 32 unset($_SESSION)['AVA']); The ) shouldn't be there after $_SESSION. make sure you're saving your .php files as UTF-8 encoding (without the BOM)
  25. This is not a PHP question. Should of posted in CSS Help To answer you question Have a look at this article http://kyleschaeffer.com/development/pure-css-image-hover/
×
×
  • 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.