Jump to content

MarioApprentice

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by MarioApprentice

  1. oh god, its an embarement. and this is the third time on this forum. sorry for the lost time. i shall go into the nearest corner and cry.
  2. well its the sam principle and its on croatian so i had to translate it to make it more readable for you, but if it help, here it is, the same code on english. If i didn't put a colon there somewhere, its a mistake in the post, not in the actual code. $sql = 'INSERT INTO reservations(name, price, user_id, product_id, number_of_items, taken, datum_postavljanja) VALUES( (SELECT name FROM product WHERE id=:id), (SELECT price FROM product WHERE id=:id), :user_id (SELECT id FROM product WHERE id=:id), :number_of_items, :taken, :date_of_request )'; $stmt->bindValue(':user_id', $_SESSION['user']->getField('id'), PDO::PARAM_INT); // this is an object containg data from logged in user $stmt->bindValue(':number_of_items', $komadi[$counter], PDO::PARAM_INT); // index counter for the number of items user whats to order $stmt->bindValue(':taken', 1, PDO::PARAM_INT); $stmt->bindValue(':date_of_request', date('Y-m-d'), PDO::PARAM_STR); $stmt->execute();
  3. yea, this is a configured example. i have the colons when the mistake happens, i just made a mistake when i wrote the post. the question still stands. sorry about that
  4. I have a code that has to save a more than one reservation into a database. This is the code $sql = 'INSERT INTO reservations(name, price, user_id, proizvod, num_items, taken, date) VALUES( (SELECT name FROM product WHERE id=:id), (SELECT price FROM product WHERE id=:id), :user_id, (SELECT id FROM product WHERE id=:id), :num_items, :taken, :date )'; $stmt->bindValue('user_id', 5, PDO::PARAM_INT); /* same for the rest of the binded values. */ But it says that the 'number of binded variables does not match number of tokes' which is not true. I have checked it 256789521 times in the past hour like some kind of crazy person. The manual doesn't say anything about partial binding of items to be inserted. Does anyone know what the problem is?
  5. Hey everybody. I have been exploring with url rewriting with htaccess for several days. Some I understand, some i don't. What i don't are arguments in url. I have a website that has a product list. In the product list, there is a link for 'Details' on a product. The url is constructed from data fetched from a database like a name and an id so i could access the data in the file that the url points to. The link is as follows www.exampleurl.com/product-name-from-database/id-number-from-database The file i which to be redirected is called so i made this in .htaccess RewriteRule ^Article-([a-zA-Z])/([0-9]+)/? products.php?id=$1 So, the url has two parts. The first is the name of the product that has to be in url. The name of the product is known by the 'Article-', then a regular expression for the actual name. Then, the id. Now, this works. Lets say my products name is 'Coffie' and id is 56. My url gets rewritten to www.example.com/Article-Coffie/56 but 404 error arises. The server can't find products.php. Why? I've been strugelling for several days with url rewriting, read a lot of articles and documentation and still don't know how it works. All the help is welcome. Thank you in advance.
  6. That still doesn't solve my problem. Lets say i have a url on my page inside <a>. That url is localhost/someFolder/myPage.php or www.example.php/index.php, whatever you fancy. I would like to make it look like this www.example.php/replacementText with this code RewriteRule index.php$ ReplacementText I mean, i don't know if it has to be like this. I want to replace the SEO ugly www.example.php?somevar=value&somevar2=value2 into www.example.php/Seo-acceptable/Seo-acceptable2.
  7. Hello everybody. My problem is .htaccess and the replacement of url-s. I have read articles, tutorials and code snippets all afternoon and am still vague about the rules that has to be in a .htaccess regular expression. My doubts are how does it work? Does the url www.example.php/SomeReplacedName/AnotherOne has to be in a <a href=''> or does the does www.example.php?example=value%another=value2? Let's say I have a link in my page (from localhost) that looks like this <a href=/localhost/examplePage/example.php?var=value&var2=value2> Then, .htacces shoud look like this Options +FollowSymLinks RewriteEngine On RewriteRule example\.php$ ReplacementText right? But it doesn't work. On the other hand, if the link in the page looks like this <a href='/localhost/examplePage/ReplacementText> The .htaccess works with this RewriteRule ReplacementText$ example.php and the browser url display the correct url like this-> localhost/examplePage/ReplacementText with the example.php acutally being called. I know there is abundance of documentation on this subject on the web, expecially on appace documentation (that is to specific and hard for a simple problem like this), but i really couldn't find a clear explanation how this shoul work. Is .htaccess taking the url from the browser adress page or the <a> element? On what side of the .htaccess syntax should be the replacement text and on what side the actual url of the document that is in the source code? Thank you in advance for all your answers.
  8. now a related problem that i really can't solve im trying url rewrite with .htaccess and can't seem to make it work. my code is mainly copy/paste but i have some experience with regular expressions. this is my code in .htaccess RewriteRule ^FictionalFolderName/([a-zA-Z/]+)/$ index.php I would like to replace index.php and any file that has .php extension with 'FictionalFolderName' but i get errors. Also, i can't get it to work with parameters either. I would like to have it like this localhost/FolderName/FictionalFolderName/ParamaterValue/ but this doesn't seem to work. RewriteRule ^FictionalFolderName/([a-zA-Z/]+)/$ index.php?name=$1 Thank you for your help. And please, don't just give me a solution. I would like to understand this so I don't have to come here for answers.
  9. yea, i just found that out. I should search more before i ask in here. Thank you.
  10. Hello to everyone. I'm making seo friendly urls and i have a problem on localhost apache. this is my url for my page localhost/firstFolder/secondFolder/index.php and in the last folder, the htaccess resides with the following code RewriteEngine On Rewrite rule ^([a-zA-Z/]+)/$ index.php Everytime i try to access index.php in 'secondFolder', the server says 'Server Error, error 500'. I checked what error 500 means and its a general 'fit all' error so that didn't help. I tried puttin .htaccess in some other folder, but everytime the server sees the file, he throws error 500 no matter where i put the file. Is it a syntax error? This is basicily copy/paste code and i doubt it. Any help is welcome.
  11. my knowledge about php sessions is at not at proffesional level, but php sessions have a unique id from which php can distinguish them from other concurent sessions. i didn't even need google for this beacuse it makes sense on its on. that is why i'm stupid. but hey, if you think i'm not stupid, call me a genius
  12. never mind this stupid question. i'm just stupid, thats all.
  13. Hello everybody. I have a website where users can login and register. When a existing user logs in, his data (name, surname, age etc...) is saved in an object that is then saved in a session called $_SESSION['user']. I've tested it with one user logged in at a time, but not with multiple users logged in, in the same moment. What will happen if 5 people gets logged in the same moment? Will the $_SESSION['user'] be overwritten with the data from the last user logged in or does php keeps track of the concurent sessions and can distinguish one from another? I think that it can beacuse of unique session id that is stored in a cookie but google searches were somewhat vague and i couldn't find a clear answer. Thank you for your answers.
  14. the file is a script that processes data like forms... it reacts only to submit <input> fields. The SESSIONS relevant for this are set on login and when the user sends messages. Like this: Login ->$_SESSION['prikaz']; ->$_SESSION['welcome']; ->$_SESSION['userDataObject']; sendMessage ->$_SESSION['prikaz'] ->$_SESSION['message_type'] -> error message -> success message error message and sucess message are just words like, 'you have sent your message sucessfully... there was an error'. What message is outputed is up to $_SESSION['welcome'] or $_SESSION['message_type']. They are not relevant and can't mess with anything logically. They just determine message output. But $_SESSION['prikaz'] echo'es the string 'prijava' into the value of the hidden input field. That script is not the problem. Its working just fine, since it only has to set the neccessesery SESSIONs and it does that. I don't think there is a way to solve this trough posts on forum. Thanks for your help and your time, but I'll try to solve this by my self.
  15. that is it. every relevant code is in the posts above. I've got nothing left.
  16. ok. before login. array(1) { ["tablica"]=> string( "naslovna" } after liogin array(4) { ["tablica"]=> string( "naslovna" ["korisnik"]=> object(Member)#1 (1) { ["fields":protected]=> array(4) { ["ime"]=> string(5) "Mario" ["prezime"]=> string(7) "legenda" ["pass"]=> string(0) "" ["mail"]=> string(24) "maslec.krlec10@gmail.com" } } ["prikaz"]=> string(0) "" ["dobrodoslica"]=> string(0) "" } SESSION['prikaz'] gets set when i want to show the <div class='prijava'>. The actual message of that element depends wether i'm sending a message, logging in ($_SESSION['dobrodoslica'] sets the welcome text) or, there is an error in the application. but SESSION['prikaz'] is only for setting the value of <input> to 'prijava'. When the user is logged in, console.log(tip) has the string 'prijava' but when logged out doesn't. That is the main problem as i said above. if(tip == 'prijava') doesn't execute. Same conditions, different results. I inspected the html with firebug and all the neccessery elements are there. Hidden <input> field has the value of 'prijava'. Everything is the same being logged in or logged out. As i said in the first post, the application should display that the message has been sent successfully via the mechanism above. When the user is logged in, it shows the message. When not, it doesn't show the message. The message is saved on the database in both ways.
  17. the only SESSION that is relevant for this problem is the $_SESSION['prikaz']. <input type='hidden' class='hidden-elem' value='<?php if(isset($_SESSION['prikaz'])) { echo 'prijava'; unset($_SESSION['prikaz']); } ?>'> and that session is set in both ways, logged in or logged out. i've checked it in both logged in and logged out. it's set and it works. i think that php has nothing to do with this but jquery, i don't know. but it's not php. thanks for you help.
  18. whell i can, but none of the session values are relevant to this example. the $_SESSION['prikaz'] only use is to put the string 'prijava' into the hidden input field. That field is a bridge of communication between jquery and php. 'prijava' is then used to show() the <div class='prijava'> with some message. but if you want it, here it is... This is logged in... array(2) { ["tablica"]=> string( "naslovna" ["korisnik"]=> object(Member)#1 (1) { ["fields":protected]=> array(4) { ["ime"]=> string(5) "Mario" ["prezime"]=> string(7) "legenda" ["pass"]=> string(0) "" ["mail"]=> string(24) "maslec.krlec10@gmail.com" } } } here are two values, 'korisnik', which holds the main data of the user like his name, surname, mail and so on and 'tablica' which does some other work that has nothing to do with this problem. This is the session when the user is not logged in... array(1) { ["tablica"]=> string( "naslovna" } The only difference is Member object when the user is logged in but that has nothing to do with this problem.
  19. it's not the session. the sessions are fine. all of them. jquery is not getting the value 'prijava' from the hidden input field when the user is not logged in. when the user is logged in, its all fine. but the sessions all work and are all set. the main question is, the code shown above is executing in the SAME form when the user is logged in and when he's logged out but its producing different results. i tried using the val() function but doesn't work. i've tried displacing the <script> tags to the end of the <body> element but nothing works. 'view source' shows that the right element is there, and that the hidden input element has the value of 'prijava' but JQuery is not picking it out. I'm sorry if this is a jquery question. i didn't know that when i was posting the question. if this post is to be erased, its cool. i'll look for the answer elsewhere. thank for your answer.
  20. Hello everybody! I'm writing an application that, among other things, allows users to send messages to admin of the page. Then, admin access it trough their CMS. After they successfully send the message, a window saying that the message was sent successfully has to appear. After clicking on OK, the message fades out with JQuery. This is the code of the message <input type='hidden' class='hidden-elem' value='<?php if(isset($_SESSION['prikaz'])) { echo 'prijava'; unset($_SESSION['prikaz']); } ?>'> <div class='prijava'> <div class='welcome'> <?php if(isset($_SESSION['poslana'])) { ?> <p class='uspjeh'>Vaša poruka je uspješno poslana</p> <p><span>Sa poštovanjem,</span><span>Tim Cvjećarnice Oliva.</span></p> <img src='images/ikone/success.png' class='ukras'> <?php unset($_SESSION['poslana']); } elseif(isset($_SESSION['dobrodoslica'])) { ?> <h1>Dobrodošlao/la na stranicu <span>Cvjećarnice Oliva</span></h1> <p>Na ovoj stranici možete naći najbolji asortiman cvijeća i ukrasnih aranžmana u Osijeku. Ako vas zanima nešto više o pojedinom cvijetu koji vam se sviđa, za vas smo pripremili i članke, koji na zanimljiv način opisuju i govore o cvijeću. Nadamo se da ste zadovoljni. Također, možete nas osobno posjetiti na našoj adresi, Vjenceslava Hodaka 16, Osijek. Veselimo se budućem susretu! <span>Sa poštovanjem,</span><span>Tim Cvjećarnice Oliva.</span> </p> <img src='images/dekoracija.png' class='ukras'> <?php unset($_SESSION['dobrodoslica']); } elseif(isset($_SESSION['fail'])) { ?> <p class='fail'>Došlo je do pogreške. Ispričavamo se na neugodnosti i molimo da, nakona nekog vremena ponovno pokušate. Hvala vam na strpljenju.</p> <p><span>Sa poštovanjem,</span><span>Tim Cvjećarnice Oliva.</span></p> <img src='images/ikone/close.png' class='ukras'> <?php unset($_SESSION['fail']); } ?> <button>Ok</button> </div> <?php ?> </div> The language is croatian and the content is irrelevant. The main thing is, if $_SESSION['prikaz'] is set, then the value of the hidden field is populated with the string 'prijava'. The $_SESSION['prikaz'] gets populated in antoher script and he isn't the problem beacuse, he is set every time and in every situation. That input field is important for the JQuery code that follows... $('.prijava').hide(); var tip = $('.hidden-elem').attr('value'); if(tip == 'prijava') { $('.prijava').show(); $('.prijava .welcome button').click(function() { $('.prijava').fadeOut(500); }); } JQuery then takes the value of the value attribute of .hidden-elem and checks if its equal to 'prijava'. If it is, then it shows the <div class='prijava'>. The problem is this. When the user is logged in, the messages shows with no problem. But when the user is not logged in, the message does not show, but it gets proccessed with inline style='display:none'. The value of the .hidden-elem is populated with the string 'prijava' but $('hidden-elem').attr('value') doesn't return the value of that hidden input element, thus if(tip == 'prijava') doesn't evaluate to true. I don't understand how can one behaviour be valid for, when the user is logged in and when he isn't if the script is operating with identical data in both cases? I know this is a long post and I thank anyone who tries to solve it.
  21. I didn't solve the problem but i read the readme file of phpmailer what i didn't do the last time. i'm an idiot. Anyway, it said that i have to set the include_path so that php know where to find phpmailer. I did that with the ini_set() function but still with no success to successfully load the mailer. Ive used $_SERVER['DOCUMENT_ROOT'] which gives me a path beyond my public_html on the host and i used it but still doesn't work. I've also used th .: notation to tell php to look for files from the current directory and still, the page chrashes upon require_once('PHPMailer_v5.1'). If anyone has a suggestion on what to do, please tell.
  22. Hi everyone. I'm having a lot of trouble with loading phpmailer. All my files are on bytehost and for the last few day, i've tried to send mail with this extension and repeaditly failed but just now I have managed to send a mail from localhost with phpmailer. But from a host, it doesn't work. I wouldn't even load the files with the call require_once('PHPMailer_v5.1'). I just get a blank screen, no warnings and no messages. Does anyone know what seems to be the problem? Also, the sendmail_path in php.ini isn't the same on host and on the localhost. I've changed it in the class.phpmailer.php file. Did i make a mistake with that or is that the way to set up mail on host? Thank you in advance for all answers!
  23. Hey everyone. The mail() function wont send mail(). The return value is true, but the mail wasn't received. That was the first thing i tried. The second was the Mail.php from PEAR, mainly sending mail from gmail but that also didn't work. I didn't even want to upload the files from it. When I put a require_once(Mail.php), nothing happens and my program crashes with no warning or errors. Just a blank white screen. I've tried a lot of links from the google. Some of them are http://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page read this-> http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html https://forums.digitalpoint.com/threads/how-to-use-gmail-to-send-emails-in-php-using-phpmailer.871893/ when using other libraries like phpmailer or Mail.php from Pear, i tried everything i could think of. Changing prot from 465 to 25 even though its the default in phpmailer, changing stmp.gmail.com or ssl://smtp.gmail.com, messing with the phpmailer scripts and other things but nothing didn't help. Ive gone through many tutorials about phpmailer and Mail from Pear but couldn't make it happen. Eventualy, when all of it didn't work, i came back to php mail() function. This is the code... Thank you in advance for every help you give me. $to = 'emalToSend@gmail.com'; $subject = 'The subject'; $message = 'Some message'; $headers = 'From: me@gmail.com' // and other like reply-to and so on... mail($to, $subject, $message, $headers);
  24. wow, that was fast. and simple. thank you.
  25. Hey, everybody. I have a problem with session and an object. This is the deal. I'm writing a forum for exercise. Now doing a login/logout script/part of the forum. The script knows that the user is logged in via a session variable that, when set and filled with a certain value, allows a registered user to log in. When someone tries to login, i check in mysql table if his nick and passwords are there. If they are there, i summon another function that gets all of the data about that user and stores it in an object. I then store that object into a session in order to get the users data in another script. After the object has been made all all the user data stored in it and after that object is stored in a session, I then route the program to index.php who then evaluates is the session is set and checks its value. Then it calls antoher function that has to use the object stored in that session. for example... $_SESSION['member_object']->getValue('name') fetches the name of the user. But here comes the problem. I get a fatal error like this... "The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Member" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function..." I presume this says that 'member_object' is not an object, which I checked with is_object() and it really is not an object. I did a require() on the script that has the class that the object was made of, but with no success. I also checked if the object is made in the login.php script and all the information are there which is the main problem. The script then goes to index.php with the header() function, and uses that session where the object is. But there, that object isn't constructed. It's not even an object. I know this is a long question and i probably didn't give enough information to go on, but its a big application and i can't risk of explaining it all so no one will answer. Also, i think it would be rude of me so if anyone knows what this could be, I thank you in andvance.
×
×
  • 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.