Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. You need to wrap your variables in curly braces. position: absolute; top:{$pos_y}px; left:{$pos_x}px; If you do not then php will think the px is part of the variable name.
  2. Why does the data need to be copied into another table? Databases should not be treated like spreadsheets.
  3. You have spelled from incorrectly on this line mail ( $email, $subject, $message, "From:".$form);
  4. You are getting that notice because the index 'movement' does not exist within $_REQUEST array. On all input variables you should check they exist before using them. A few examples $movement = ''; if(isset($_REQUEST['movement'])) $movement = $_REQUEST['movement']; // or using ternary operator $movement = isset($_REQUEST['movement']) ? $_REQUEST['movement'] : ''; On your old server either error reporting was set to ignore notices or it was configured so errors would not be displayed.
  5. Easiest way would be to define the new contents of config.php as a string and for each variable substitute its value with the corresponding value from your form. Then write the new contents to config,php Eg Also change your forms submit method to post. Do not use get when submitting sensitive information. if (isset($_POST['submit'])) { /* Get the results from the HTML Form */ $hostValue = $_POST['host']; $databaseValue = $_POST['database']; $usernameValue = $_POST['username']; $passwordValue = $_POST['password']; /* Replace the database connections in config.php */ $newConfigCode = '<?php $host = "'.$newHostValue.'"; $username = "'.$newUsernameValue.'"; $password = "'.$newPasswordValue.'"; $database = "'.$newDatabaseValue.'"; /* Change this line in the HTML Form in setup.php */ $dbc = mysqli_connect($host, $username, $password, $database); ?>'; // overrite config.php with new config file_put_contents('config.php', $newConfigCode); }
  6. To get the users session id you can called session_id() after you have called session_start() eg. session_start(); // get the session contents $contents = file_get_contents('scripts/session/sess_' . session_id()); But why do you need to read the session file yourself? PHP automatically does this when you call session_start(). If you want to override how PHP handles sessions you can write your own session handler, see the documentation on session_set_save_handler. The session_set_cookie_params() function only affects the cookie not the physical session file.. The files for expired session are deleted automatically by the garbage collection process.
  7. Yes, provided the session has not expired.
  8. Try changing these lines while (! feof($fp)) { $parts = fgetcsv($fp, 0, '|'); echo fgets($page). "<br />"; if (count($parts) !== 4) { continue; } to while (($parts = fgetcsv($fp, 0, '|')) !== FALSE) { if ((count($parts) != 4) || (strpos($parts[1], '/stream') === false)) { continue; }
  9. This is not a PHP question/problem. It requires a few lines of HTML/Javascript What you need to is add your html link(s) to the page. Apply an onclick handler to your links using jquery, fetch the ip address and port number from then href attribute of the link that was clicked and pass this info to the fetch_info_data() javascript function (located in assets/main.js). The rest will be handled by the GoldSouce-Server script for you.
  10. You dont want to use return in the while loop. What you should do loop over the results from the query, build a string containing the html for the links and then return the generated html after the loop. $results = ''; while($result = $db->fetch_array($page_query)) { // build the links $results .= '<li> <a href="index.php?page='. $result['id'] .'">'.$result['name'].'</a> </li>'; } // return page links return $results;
  11. What! So in the 10 years you have never heard of or done paged results from from a database? Its one of the things I first learned when dealing with PHP/MySQL.
  12. Yes you would need to use a foreach loop to output all rooms returned in the json. if (!empty($roomobj)) { // loop over all rooms foreach($roomobj as $room) { if ($room->{'Room Type'} == 'Bedroom') { echo '<li role="presentation"><a href="#bedroom1" aria-controls="bedroom1" role="tab" data-toggle="tab">'; echo ($room->{'Room name'}); echo '</a></li>'; } } } echo '</div>'; // closes tabpanel div
  13. This is because dropdown menus cannot contain newlines.
  14. You have given all your input fields the same name of email <input type="text" name="email" ... All fields in a form must have a unique name.
  15. Please not when posting code to wrap it within tags or click the <> button in the editor. The only thing I can suggest is to make sure you have used unique names for the Email and Morada form fields and that you are using the correct variables in the php code where it updates these fields.
  16. You can close a thread but you can mark it as solved by clicking the Best Answer button.
  17. The [] should not in be included in the key for $_POST['url[]'] and $_POST['price[]']. They should be like so $_POST['url'] $_POST['price'] PHP will automatically convert form values where the field name contains square brackets into a multidimensional array. Yes you would need to some form of loop to get their individual values, eg // loop through urls foreach($_POST['url'] as $url) { // do something } // loop through prices foreach($_POST['price'] as $price) { // do something } If you want to process the url and price together then you could do it with one loop eg // loop through urls foreach($_POST['url'] as $k => $value) { $url = $value; $price = $_POST['price'][$k]; // do something }
  18. Use isset when checking to see if a session variable exists if (isset($_SESSION[$par])){ The fetch() method is part of PDOStatement object ($row) not the PDO object ($connect). $result = $connect->query("SELECT * FROM uyeler WHERE uye_kadi = '$kadi' && uye_sifre = '$sifre'"); $row = $result->fetch(PDO::FETCH_ASSOC);
  19. Those links do not work. Attach screenshots to your post. That is your database password.
  20. Code for config.php looks ok to me. However you should add error checking to your code to know why the database connection is failing. <?php @session_start(); $connectdb=mysql_connect("localhost","7milimetros","Chetan123") or trigger_error('Unable to connect to mysql: ' . mysql_error(), E_USER_WARNING); $usedb=mysql_select_db("7milimetros",$connectdb) or trigger_error('Unable to select databae: ' . mysql_error(), E_USER_WARNING); $_SESSION['token']=session_id(); ?> This will either force an error message to be shown or it will be logged in your servers error logs.
  21. If you are going to be loading the contents with ajax when the links are clicked then you need to override their default behavior, so the browser does not redirect the user when they are clicked. You can use return false; at the end of of your .click() function or call jquery's .preventDefault() function. Also if you are going to be using jquery then there is no need to initialize the xmlhttprequest object yourself. Jquery provides a very easy to use .ajax object for you.
  22. Try using full php tags <?php ?> and not short tags <? ?> Also either check your severs error logs or enable error reporting.
  23. You can store the data in a text file. You would only perform the curl request if the file does not exists or when a certain time period has passed (eg every 6 hours). Example code <?php define('UPDATE_INTERVAL', 60*60*6); // set update interval, eg 6 hours define('DATAFILE', 'data.json'); // file to store the data in $timeSinceUpdated = 0; // if the datafile exists if(file_exists(DATAFILE)) { // get the time when the datfile was last updated/created $lastModified = filemtime(DATAFILE); // get the time passed since the file has been updated/created $timeSinceUpdated = time() - $lastModified; // decode the data from the datafile $data = file_get_contents(DATAFILE); $data = json_decode($data); } // if the file does not exist, or the the update interval has passed // perform curl request and update the data if(!file_exists(DATAFILE) || $timeSinceUpdated >= UPDATE_INTERVAL) { include('simplehtmldom_1_5/simple_html_dom.php'); // Create DOM from URL or file $html = file_get_html('http://sportsfeedia.com/nfl/'); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $html); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); $str = curl_exec($curl); curl_close($curl); // overwrite the data $data = array(); // Find all links, and their text foreach($html->find('a[class=itemtitle]') as $elm) { $link = $elm->href; $text = $elm->plaintext; $news = str_replace("new","*",$text); // add new data to array $data[] = array($link, $text, $news); } // json encode the data and save to the datafile file_put_contents(DATAFILE, json_encode($data)); } // output links foreach($data as $contents) { list($link, $text, $news) = $contents; ?> <?= $news ?><BR> <a href=<"<?= $link ?>">Read More</a><br> <?php } ?>
  24. You need to wrap your links in a condition to only display if no page has been specified if(!isset($_GET['page'])) { // output links } // your switch/case statement here
  25. You do not need to "disconnect and reconnect" to query a different table that is on the same server and in the same database.
×
×
  • 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.