Jump to content

MarioApprentice

Members
  • Posts

    36
  • Joined

  • Last visited

MarioApprentice's Achievements

Member

Member (2/5)

0

Reputation

  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.
×
×
  • 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.