Saturday 15 February 2014

mysqli - Why does my php code not send its data to the database I have created? -


I am new to php and I have seen a question on that person's website, whose problem was the same but the answer The problem did not help my situation. I can not insert records with my PHP code in my database.

Here is my code that I have followed a textbook called 'PHP for absolute beginners' by Jason Langstorf. I can attach the remaining code in a comment if you need it, and you can also get the code on this website under source code. Where is my problem and where I would like to update the database, it starts at line 66, which I have commented to show you next to another statement:

   
" This image prints "} Catch (exception $ E) {Dead ($ e-> getMessage) );}} And {$ img_path = NULL;} // include database credentials and include in the database_on 'db.inc.php'; $ Db = new PDO (DBNXFO, DB_USER, DB_ PASS); "Image Path" resonates Is $ img_path, "& lt; //; go out; edit in the book, but not on the source // edit an existing entry (! ($ _ POST ['id'])) {$ sql = "Entries entry SET title =?, Entry =?, Url =? WHERE id = "border1"; $ Stmt = $ db- & gt; Ready ($ sql); $ Stmt- & gt; Execution (array ($ _POST ['title'], $ img_path, $ _POST ['entry'], $ url, $ _POST ['id'])); $ Stmt- & gt; CloseCursor (); } // Problems with a new entry and // line 66 issues code do not work till this line {// Save the entry in the database echo "Please work at this time"; $ Con = mysqli_connect ("localhost", "root", "", "simple_blog"); If (mysqli_connect_errno ()) {echo "failed to connect to MySQL:". Mysqli_connect_error (); } $ Page = $ _POST ['page']; // var_dump ($ page); $ Page = mysql_real_escape_string ($ page); $ Heading = $ _POST ['title']; // var_dump ($ title); $ Title = mysql_real_escape_string ($ title); $ Entry = $ _POST ['entry']; // var_dump ($ entry); $ Entry = mysql_real_escape_string ($ entry); $ Sql ​​= "Enter in Entries (page, title, image, entry, url) value ('$ page', '$ title', '$ img_path', '$ entry', '$ url')"; Mysqli_query ($ conn, $ sql); Mysqli_close ($ thief); } // Store page information for use in successful URL $ page = htmlentities (strip_tags ($ _ POST ['page']);; // Send the user to the new entry "Hopefully we come here"; Header ('location: / simple_blog /' page. '' '' .url); Go out; } And {header ('location: ../'); Go out; }? & Gt; Anyone can tell me why my code does not post in the database, I appreciate the help and I thank you.
Post text "itemprop =" text ">

You are matching and matching different database libraries 3 None of them are compatible with each other Results from one other The following is a flat-out operation error:

  $ page = mysql_real_escape_string ($ page); ^ --- One i mysqli_query ($ conn, $ sql) Note the lack of; ^ - Note that one of your D   

is making a mistake on all the attendance failure and the first dilemma After leaving the trail of chaos and destruction, if you have an error related error, then you may have seen errors:

Additionally, mysql (without any one) is disliked and never It should not be used. If you have started with PDO, then do not mix DB libraries with PDO.

No comments:

Post a Comment