Jump to content

zetcoby

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

zetcoby's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thank you guys, it helped me a lot , now i understand it, finally ^^
  2. okay i have a problem understanding things like this one parent::__construct(); i would appreciate if someone can explain me what the ' :: ' means i know what a construct is, the strange part for me is that i found that many times in a other construct something like this: function __construct() { parent::__construct(); }
  3. well what i did there was a db where i store all the variables and values (valeus are all text ) witch i use for language for a site, i got 2 tables. lang_ro and lang_hu each table has 4 columns `id`,`var`,`val`and `page` in var i store the variable name, in val the content of that variable and in page the page that they belong (a keyword of the page); so to retrive data from the db i do it like this if (isset($_SESSION['lang'])) { if ($_SESSION['lang'] == 'ro') { $sql = mysql_query("SELECT var, val FROM $lang_ro"); $lang = array(); while ( $row = mysql_fetch_assoc($sql)) { $lang[$row['var']] = $row['val']; } }else if ($_SESSION['lang'] == 'hu') { $sql = mysql_query("SELECT var, val FROM $lang_hu"); $lang = array(); while ( $row = mysql_fetch_assoc($sql)) { $lang[$row['var']] = $row['val']; } } }else{ $sql = mysql_query("SELECT var, val FROM $lang_ro"); $lang = array(); while ( $row = mysql_fetch_assoc($sql)) { $lang[$row['var']] = $row['val']; } } now the reason i made the table like that is: i made an admin panel where the admin can enter, he selects the page then the language he wants to edit and after he selected everything, all the the values from the page he selected will appear in inputs and he can easily edit what he wants and then click save and update the db only in the fields he edited. P.S. now i try to make it in such way that it will check to see if the array that is needed was already retrieved from the DB so it wont retrieve it every-time when the page changes
  4. but i am not repeathing the same thing every time there is a other column and a other Where condition
  5. is there a other way to write this? mysql_query("UPDATE $lang_ro SET val = '$nav_home' WHERE var = 'nav_home'"); mysql_query("UPDATE $lang_ro SET val = '$nav_project' WHERE var = 'nav_project'"); mysql_query("UPDATE $lang_ro SET val = '$nav_forum' WHERE var = 'nav_forum'"); mysql_query("UPDATE $lang_ro SET val = '$nav_db' WHERE var = 'nav_db'"); mysql_query("UPDATE $lang_ro SET val = '$nav_contact' WHERE var = 'nav_contact'"); mysql_query("UPDATE $lang_ro SET val = '$nav_faq' WHERE var = 'nav_faq'");
  6. thank you very much ! ! ! it worked
  7. thank you i will try it out right now
  8. hi guys, i wanna make a multilingual site that will store all the content in a DB for each language, i want it easy to edit for other persons using a admin panel, that is why i want to use a DB. The thing that i need to retrive data from the DB and insert it in to array. and in DB i wanted to do it like this: |++ID++|++++VAR++ |+++++++VAL+++++++| |++1++ |+++title+++ |++Welcome to my site++| |++2++ |++content++ |++some content+++++++| When i get this from the DB i want it to put it all in array like this: array( 'title' => 'Welcome to my site', 'content' => 'some content');
  9. i found the problem, it seems that the header function needs time to execute so all i had to do was to insert a die function after each header,
  10. hello, i have a small problem with my file upload script, for some reason the file size or and the file extensions conditions wont work, and i don`t know why, everything else works fine, if i wanna upload a file that has the right size it will upload, or if i upload a php file this one will upload too, i dont know why the condition wont kick in if (isset($_FILES['file'])){ $target = "../../uploads/"; $rand = rand(1, 9999); $target = $target . $rand . basename( $_FILES['file']['name']) ; $file_size = $_FILES['file']['size']; $file_ext = strtolower(end(explode('.', $_FILES['file']['name']))); if ($file_size >= 12000000) { header("Location: ../files/post?error=2&cid=".$cid); } if ($file_ext == 'php') { header("Location: ../files/post?error=3&cid=".$cid); } move_uploaded_file($_FILES['file']['tmp_name'], $target); }
  11. Hello, i am a bit confused, where is the best place to write the code of a form? in the same file where the forum it self is located or in a other php file? what structure to use? how do u guys organized you site files? can someone please tell me what is the best way to organize your files in folders? but a other way besides MVC, the problem is that i don`t use frameworks yet, i am still learning php.
  12. i wanna know what is the best way to deal with the database, by that i mean: >>> if i have a huge project and every time a user logs on a page to view the goods that are for sale how can i make it so that if he goes to an other page and after a while return back to the goods page, i want that page not to take the info again from the DB but mantain it somewhere, all i want is to check if the DB has updated so only then the page should take the info again from the DB... I dont reall know how to put this.... all i wan is to use the DB less not using a query every time i need some info from the DB Is there a way to do this?
  13. hi guys, i am trying to create a button that when u press if in the text are will appear <video>...</video> i know this is js do don't worry i will manage to do it, my problem is in php, i did a function that recognizes the link between <video>...</video> and then it embades it and shows me a youtube video instead, the problem i got is that if i have in the text area more <video>...</video>, like: bla bla bal<video>youtube link</video> and the other vid <video>youtube link</video> i dont know how to make it embade both, i dont know how to check if there is more, and the second problem i got is that all the text that was not betwen <video>...</video> will disapear after the vide is embadded, here is the code i done until now <form action="test1.php" method = "POST"> <textarea name="body" id="text" cols="30" rows="10"></textarea> <input type="submit" value = "submit"> </form> <?php function video($string){ preg_match_all("#<video\b[^>]*>(.*?)</video>#", $string, $output); preg_match_all("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $output[0][0], $match); return "<iframe width='560' height='315' src='http://www.youtube.com/embed/".$match[0][0]."' frameborder='0' allowfullscreen></iframe>"; } if (isset($_POST['body'])&&!empty($_POST['body'])) { $body = $_POST['body']; print_r(video("$body")); } ?>
×
×
  • 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.