php code does not parse correctly please help

Alles, was PHP betrifft, kann hier besprochen werden.

php code does not parse correctly please help

Postby dariusd7 » 03. November 2013 01:53

First forgive me if the code is not in an organized manner, I have tried to insert code in a neat manner but by the time I fix it, the system times out, so I cant post and have to do it all over this time I am not going to adjust the code.. just copy past it into forum

I created a from called product_insert.html.. and a php script called product_insert.php. They are both located in a sub folder called Final exam, in the htdoc folder of xampp.

After entering data into form, the next screen basically shows me the script of the product_insert.php. I cannot figure out why it does not make the connection. Also the database is called final_exam.

Code: Select all
      $host = "localhost"; // change this as required
      $username = "root"; // change this as required
      $password = "password"; // change this as required
      $db = "final_exam"; // your DB 

         $DBConnect = @mysqli_connect("localhost", "root", "password")
            or die("Could Not Connect");
         //echo "We have successfully connect to our DB.<br/>";
         @mysqli_select_db( "final_exam")
            or die(mysqli_error());
         //echo "Successfully opened DB.<br/>";
         //pull values from the URL and put them each in a variable
         $Description = addslashes($_GET["Description"]);
         $Quantity = addslashes($_GET["Quantity"]);
         $Price = addslashes($_GET["Price"]);
         $Vend_id = addslashes($_GET["Vend_id"]);
         if($Description && $Quantity && $Price && $Vend_id)
            echo "test1";
            echo "test2";
         /*if(isset($Description) && !empty($Description)
            && isset($Quantity) && !empty($Quantity)
            && isset($Price) && !empty($Price)
            && isset($Vend_id) && !empty($Vend_id))
            $SQLstring = "INSERT INTO product (vend_id, Quantity, Price, Vend_id)
               VALUES ('$Description', '$Quantity', '$Price', '$Vend_id')";
            $QueryResult = @mysql_query($DBConnect, $SQLstring)
               Or die("Insert Broke!!!");
            echo "insert complete";
            echo "You are missing some values...Please press the back button and retry!";
         //redirect back to our list page since the insert worked
         header("location: product_list.php");   */   

<a a href="product_insert.html">Click here</a> to go back to the list!-->
Posts: 1
Joined: 03. November 2013 01:43
Operating System: windows7

Re: php code does not parse correctly please help

Postby Nobbie » 03. November 2013 23:10

What did you enter in the browser URL line to load the first HTML Document (which calls your PHP Script)?

You *MUST* *NOT* double click on HTML files in your explorer - what you did (i assume)?!
Posts: 8634
Joined: 09. March 2008 13:04

Return to PHP

Who is online

Users browsing this forum: No registered users and 4 guests