Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. What have you tried so far?
  2. phpbb2 support ended in 2009! 4 years ago. You may find small group of people maintaining that version but don't expect miracles. I would drop pphbb2 and convert to phpbb3 asap. I prefer security/support over what a forum looks like. Why not try skinning phpbb3 yourself or see if someone can do it for you.
  3. It is because your paths are relative. If you are on the page at http://site.com//12/how-to-lose-weight/ and you have link in your page like <a href="contact-us.php">Contact Us</a> Then when you hover over the link you'll see the url becomes http://site.com//12/how-to-lose-weight/contact-us.php which is not what you want. If your links is <a href="/contact-us.php">Contact Us</a> And then hover over your link you'll see the link is point to the correct location http://site.com/contact-us.php. The / makes your urls absolute rather than relative. relative urls get appended to what the current url (the page you're on for example http://site.com//12/how-to-lose-weight/). You'll need to modify your existing urls (this includes links, stylesheets, images, javascripts etc) to work with your mod_rewrite urls. Otherwise you find issues like this. The simple work around is to start all urls with a / to make them absolute rather than relative.
  4. What do you mean didn't work? Whats the code you're using for creating the contact-us.php link? What is the url that causes to not work correctly
  5. There are many ways to modify text with PHP. Some functions you can use str_replace or substr or using regualr expressions with preg_replace You can use trim Ask as many questions as you like
  6. You'll want to modify the SongTitle database field so its a unique/primary key. Then you can change your INSERT query to an INSERT IGNORE query, MySQL will then ignore any duplicate entries with the same song title This may help you further. http://www.tutorialspoint.com/mysql/mysql-handling-duplicates.htm
  7. Thats not mod_rewrite doing it. Its the web browser. It thinks 12/how-to-lose-weight-fast/ is a directory, even though they dont exist. The web browser is appending contact-us.php to end of the current url. To prevent this start your urls with a / Example link. <a href="/contact-us.php">Contact Us</a> If a url starts with a / then the browser will load the link from the root of the site (http://site.com) regardless of what the current url is. You'll want to have read about absolute and relative urls.
  8. This problem is most probably on this line if(( $_FILES["file"]["type"]=="image/png")||($_FILES["file"]["type"]=="image/jpeg")||($_FILES["file"]["type"]== "image/jpg" )||($_FILES["file"]["type"]=="image/gif")&& ($_FILES["file"]["size"]< 2)&& (in_aray($extention,$allowedex))) It is very hard to read and your most probably have a logic error some where. Code cleaned up. The script should operate as expected // define allowed file types in an array $allowedTypes = array( 'image/png', 'image/jpeg', 'image/jpg', 'image/gif' ); // define allowed file extensions in array $allowedExt = array("png", "jpeg", "jpg", "gif"); // define max file size to be uploaded (this needs to be in bytes) $maxFileSize = 102400; // 100KB max file size (100 * 1024) theres 1024 bytes in 1KB // check that form has been submitted if(isset($_POST['submit']) && is_array($_FILES)) { // get the file type $fileType = $_FILES['file']['type']; // get the file extension using pathinfo function $fileExt = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); // get fileSize $fileSize = $_FILES['file']['size']; // check that // - fileType is in allowTypes array, // - fileExt is in allowedExt array and // - fileSize is not bigger than maxFileSize if(in_array($fileType, $allowedTypes) && in_array($fileExt, $allowedExt) && ($fileSize < $maxFileSize)) { if($_FILES['file']['error'] > 0) { echo "Error" . $_FILES["file"]["error"]; } else { move_uploaded_file(($_FILES["file"]["tmp_name"]),"images/uploads/".$_FILES['file']['name']); echo "Your upload was successful"; } } else { echo 'problem'; } }
  9. $client->GetSequenceNo(array()); Appears to return an object which is assigned to $result variable. To access an objects property you'd use this format $object_name->property_name. A property is like a variable but it belongs to the object. As you want to get the iServerNo and iClientNo you could try echo $result->iServerNo . '<br />' . $result->iClientNo If you've not used objects/classes then you should read up on Object Orientated Programming (OOP for short). Here is an introduction Also no need for the objectToArray() function just use print_r or var_dump.
  10. You'd set the form action attribute to submit.php ie: <form action="submit.php" method="post"> When the forms submit button is pressed the form will go to submit.php with the information entered in the form. Then in submit.php change <Dst_nbr>923665487745</Dst_nbr> <Mask>STAFF</Mask> <Message>"A task is due, Please check your email or Login into the Dashboard."</Message> To <Dst_nbr>'.$_POST['dst_nbr'].'</Dst_nbr> <Mask>STAFF</Mask> <Message>"'.htmlentities(strip_tags($_POST['message']), ENT_QUOTES).'"</Message>
  11. Are you sure PHP is reading the php.ini? Can you confirm echo php_ini_loaded_file() . '<br />'. ini_get('upload_max_filesize'); outputs 20M and the correct path to the php.ini file you're editing
  12. By fields do you form fields in a webpage? You can get the values from submitted form fields using $_POST superglobal variable, so long as the form is using the post method. Example form code <form method="post"> Dst_nbr: <input type="text" name="dst_nbr" /><br /> Message: <input type="text" name="message" /><br /> <input type="submit" name="submit" value="submit" /> </form> <?php if(isset($_POST['submit'])) { $dst_nbr = $_POST['dst_nbr']; $message = $_POST['message']; echo 'You posted<br />Dsn_nbr =' . $dst_nbr . '<br/>Message = ' . $message; }
  13. When you modified php.ini did you restart your http server? Depending on how the server is setup you need to restart http server for changes to php.ini to take effect.
  14. maybe these articles might help you The following article explains how to handle/store Hierarchical Data with MySQL with example data and queries. http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ The article gives example with PHP code http://www.sitepoint.com/hierarchical-data-database-2/
  15. First you'll need check if the key exits then initiate it. $key = $vote['type']; // use the vote as the key if(isset($votes[ $key ])) // check if current vote exits. If it does increment vote by 1 $votes[ $key ]++; else // vote doesn't exist yet. Add vote to votes (creates new key). Initiate vote with 1 $votes[ $key ] = 1; To display the result of the votes rather than echo '<pre>'.print_r($votes],1).'</pre>'; You can do echo "<h1>Vote Results</h1>"; foreach($votes as $vote => $count) { echo "<b>$vote</b> has $count votes<br />"; }
  16. Are your trying to do a breadcrumb? For example a breadcrumb menu like Home > Tutorials > PHP > what ever Home is id 0 Tutorials is id 5 PHP id 100 wahat ever is id 105 Then from what ever menu traverse backwards to get the parents name and display a menu?
  17. Use this code for facturen-new.php <?php /* Staat de gebruiker toe om nieuwe records toe te voegen te bewerken */ // connect to the database include("connect-db.php"); # errors weergeven ini_set('display_errors',1); // 1 == aan , 0 == uit error_reporting(E_ALL | E_STRICT); // Maakt nieuw/edit record formulier function renderForm($bedrijfsnaam ='', $factuurbedrag ='', $vervaldatum ='', $voldaan ='', $opmerkingen ='', $id ='', $error = '') { $title = (empty($id)) ? "New Record" : "Edit Record"; // all HTML is now held within the $HTML variable. $HTML = <<<HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>$title</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <h1>$title</h1> $error <form action="facturen-new.php" method="post"> <div> HTML; // DO NOT MOVE?CHANGE THE ABOVE LNE if (!empty($error)) $HTML .= "\n<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>\n\n"; if(!empty($id)) $HTML .= '<input type="hidden" name="id" value="' . $id . '" /><p>ID:' . $id .'</p>'; $HTML .= <<<HTML <strong>Bedrijfs(naam):</strong> <input type="text" name="bedrijfsnaam" value="$bedrijfsnaam"/><br/> <strong>Factuurbedrag:</strong> <input type="text" name="factuurbedrag" value="$factuurbedrag"/><br/> <strong>Vervaldatum:</strong> <input type="text" name="vervaldatum" value="$vervaldatum"/><br/> <strong>Voldaan (ja/nee):</strong> <input type="text" name="voldaan" value="$voldaan"/><br/> <strong>Opmerkingen:</strong> <input type="text" name="opmerkingen" value="$opmerkingen"/><p/> <input type="submit" name="submit" value="Submit" /> </div> </form> </body> </html> HTML; // DO NOT MOVE/CHANGE THE ABOVE LINE // function returns the generated HTML return $HTML; } // set action to create a new record $action = 'new'; // override action to either edit or update if(isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { // get the record id from _GET or _POST $id = (int) $_REQUEST['id']; // what action we're doing // if id is in url eg: facturen.php?id=1 then we're editing the record // If its not in the url then we're updating the record $action = isset($_GET['id']) ? 'edit' : 'update'; } // if the form has been submitted if(isset($_POST['submit'])) { $bedrijfsnaam = htmlentities($_POST['bedrijfsnaam'], ENT_QUOTES); $factuurbedrag = htmlentities($_POST['factuurbedrag'], ENT_QUOTES); $vervaldatum = htmlentities($_POST['vervaldatum'], ENT_QUOTES); $voldaan = htmlentities($_POST['voldaan'], ENT_QUOTES); $opmerkingen = htmlentities($_POST['opmerkingen'], ENT_QUOTES); // run query depending on actions if($action == 'new') // inserts new record { $stmt = $mysqli->prepare("INSERT INTO facturen SET bedrijfsnaam = ?, factuurbedrag = ?, vervaldatum = ?, voldaan = ?, opmerkingen = ?"); $stmt->bind_param("sssss", $bedrijfsnaam, $factuurbedrag, $vervaldatum, $voldaan, $opmerkingen); } elseif($action == 'update') // updates record { $stmt = $mysqli->prepare("UPDATE facturen SET bedrijfsnaam = ?, factuurbedrag = ?, vervaldatum = ?, voldaan = ?, opmerkingen = ? WHERE id=?"); $stmt->bind_param("sssssi", $bedrijfsnaam, $factuurbedrag, $vervaldatum, $voldaan, $opmerkingen, $id); } // executes query and redirects on sucess if($stmt->execute()) { header('Location: facturen.php'); exit; } else { $error = 'Cannot continue! Error with database'; } // otherwise display form with error echo enderForm($bedrijfsnaam, $factuurbedrag, $vervaldatum, $voldaan, $opmerkingen, $id, $error); } elseif($action == 'edit') { $stmt = $mysqli->prepare("SELECT * FROM facturen WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $bedrijfsnaam, $factuurbedrag, $vervaldatum, $voldaan, $opmerkingen); $stmt->fetch(); echo renderForm($bedrijfsnaam, $factuurbedrag, $vervaldatum, $voldaan, $opmerkingen, $id); } else echo renderForm(); // sluit mysqli verbinding $mysqli->close(); ?> I have gone through it and cleaned it up. You had a lot of repetitive code which was redundant. The script should work fine I have tested that it edit/update/create new records in the database.
  18. Yeah you can do that. As one line in the within the foreach loop $file = file('data.json'); // each line gets added to the $file array $votes = array(); // initiate $votes to an array foreach($file as $line) { $vote = json_decode($line, true); // json decode current line $votes[ $vote['type'] ]++; // add vote to array } // display votes count echo '<pre>'.print_r($votes],1).'</pre>'; My orginal code adds all vote types to an array as a new item. I then count the votes using the array_count_values function. Which will give the exact same result as above.
  19. You've lost me. date('z'); will give you the day of the year. It'll reset to 1 on 1st Jan 2014 tho.
  20. How are you setting sessions? How are you getting session vars?
  21. Still need more info. What changes?
  22. Is this number a part of a date? You could look into using the date function http://php.net/date You need to give us more info of what this number does.
  23. Find where them words are and type them in your preferred language?
  24. Yes all php code needs to be enclosed in <?php and ?> tags
  25. No you'll need to echo out the $ip variable. Othwerwise it'll just echo the string $ip = $_SERVER['REMOTE_ADDR']; as-is. $ip = $_SERVER['REMOTE_ADDR']; echo $ip; // this will echo out the IP
×
×
  • 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.