Jump to content

MarioApprentice

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by MarioApprentice

  1. I did come up on errors. That is why i'm asking but i didnt get that far ahead to now how to keep logs but i can imagine how to do it, but the main thing I want to do is get the sql error number. Let's say i get 1062 which is for duplicate code, or when i put the values in a table that are already there and need to be unique. Then i would like to do something like this: //registration of user with the unique values repetied, exception //sql error code 1062 if(1062 == true) { //redirect to registration page with a message that the username //or password or given e-mail already exists } That's what i want. I'm learning php for 2 months and I figure there's a better way to do this, but this is the best i can understand with a 2 months knowledge. I've tried with the errorCode() method in with the PDOStatement object but it doesn't work.
  2. Hy everybody for the second time today. I'd like for my catch clause to redirect to a page regarding the mysql error given by a query. Lets say that i mispell a query and get a 1064 sql error code. how to i get it? I've tried googling but with no results. I've also found the errorCode() method that's going with PDO object and PDOStatement but it doesn't work.
  3. Hello everybody. I have a problem with an sql query and would be gratefull for some help. I can't get this to work. I tried the INSERT command on the shell and it works just fine but here, it gives me the 1064 error which is a syntax error. To get things wirder, the first call to bindValue(), the one that binds ":table_name" and "korisnicki_podaci" works, but the subsequent don't. Thank you in advance for any kind of help private static $_sqlRegistration = "INSERT INTO :tableName(ime, prezime, nadimak, lozinka, mail, registracija) VALUES(:name, :lastName, :username, :password, :e_mail, CURDATE())"; public static function userRegistration($conn) { try { $st = $conn->prepare(self::$_sqlRegistration); $st->bindValue(":tableName", "korisnicki_podaci", PDO::PARAM_STR); $st->bindValue(":name", "Marko", PDO::PARAM_STR); $st->bindValue(":lastName", "Legenda", PDO::PARAM_STR); $st->bindValue(":username", "Kreten", PDO::PARAM_STR); $st->bindValue(":password", "digital", PDO::PARAM_STR); $st->bindValue(":e_mail", "izmisljeni_mail@gmail.com", PDO::PARAM_STR); $st->execute(); } catch(PDOException $e) { throw new Exception("Statement not executed " . $e->getMessage()); } }
  4. hey, it works but all i did is close the tab that i was working in and executed the file the same way i did the las 100 times. I didnt change anything. Sorry for the false alarm
  5. no, ive created another folder localhost/htdocs/start/file.php but that shouldt me a problem, right? Ive been doing that with php code without html and it works. Im using just notepad.
  6. and im running it on local server and yes its and it is loclachost/htdocs/file.php
  7. Yes, I am. Also Also, when I put <p> inside echo it works but alone it doesnt. <!doctype html> <html> <head> <body> <?php echo "doesn't work"?> <p> <?php echo"<p>Works</p>";?> </p> </body> </head> </html> At the end, the only thing that outputs is ";?> and thats it.
  8. ok. here it is for copy/paste <!doctype html> <html> <head> <title>This is my first PHP program!</title> </head> <body> <p>This is going to be ignored by PHP and displayed by the browser.</p> <?php echo 'While this is going to be parsed.'; ?> <p>This will also be ignored by PHP and displayed by the browser.</p> </body> </html> Here it is. This is an example from google by some website. They are all the same but none of them works on me.
  9. Hey everyone, i have a basic question. I've downloaded xampp and have been going trough Programming PHP book and found that embedding php in html is a problem. I've googled this and im doing everything right. ive alo copy/pasted some code that should work but it doesn't. <head> </head> <body> <p>This is written but this [code=php:0]this is not[/code] </p> </body> </html> The question is newbie. The php output is not showing on my browser. The file is php extension not html, its in the right tags and it wont show. Also, when i embedd a HTML element inside echo, that shows but with an this: "?>. Like this <p> <?php echo "<p>Hey</p>"?> </p> This would output Hey but with addiotional "?> in a newline. Thank you for all your answers.
  10. Hi everyone, my name is Mario, Im new to PHP and have a lot of questions. Hope you'll have the patience to answer
×
×
  • 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.