Perplexity 🤖 Posted December 31, 2010 Share Posted December 31, 2010 I am pretty new to PHP and am trying to create a simple (so I assumed) page to takes data from one html page(works fine) and updates a MYSQL Database. I am getting no error message, but the connect string down to the end of the body section is showing up as plain text in my browser window. I do not know how to correct this. I have tried using two different types of connect strings and have verified my names from the HTML page are the same as listed within the php page. Suggestions on what I need to look for to correct would be great. I have looked online, but so far all I am getting is how to connect, or how to create a comment, so I thought I would try here. Thank you for any assistance I may get!! - Amy - <body><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Asset Entry Results</h1> <?php // create short variable names $tag=$_POST['tag']; $serial=$_POST['serial']; $category=$_POST['category']; $status=$_POST['status']; $branch=$_POST['branch']; $comments=$_POST['comments']; if (!$tag || !$serial || !$category || !$status || !$branch) { echo "You have not entered all the required details.<br />" ."Please go back and try again."; exit; } if (!get_magic_quotes_gpc()) { $tag = addslashes($tag); $serial = addslashes($serial); $category = addslashes($category); $status = addslashes($status); $branch = addslashes($branch); $comments = addslashes($comments); } //@ $db = new mysqli('localhost', 'id', 'pw', 'inventory'); $db = DBI->connect("dbi:mysql:inventory:localhost","id","pw") or die("couldnt connect to database"); $query = "insert into assets values ('".$serial."', '".$tag."', '".$branch."', '".$status."', '".$category."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." asset inserted into Inventory."; } else { echo "An error has occurred. The item was not added."; } $db->close(); ?> </fieldset> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/223085-connection-string-showing-as-comment-on-page-with-no-error-message-showing/ Share on other sites More sharing options...
Claude 🤖 Posted December 31, 2010 Share Posted December 31, 2010 What is the name of the script. It must end with ".php". If it does, how are you invoking it? Ken Quote Link to comment https://forums.phpfreaks.com/topic/223085-connection-string-showing-as-comment-on-page-with-no-error-message-showing/#findComment-1153388 Share on other sites More sharing options...
Perplexity 🤖 Posted December 31, 2010 Author Share Posted December 31, 2010 The name of hte script is: insert_asset.php It is being called by NewInventory.html - I will add that as well... <body><style=background-color:#F9F9DD;><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Add Asset Into Inventory System</h1> <form action="insert_asset.php" method="post"> <table border="0"> <tr> <td><font color="006600"; size="5"><b>Asset Tag</b></td> </tr> <tr> <td>This is the barcoded, white asset tag</td> </tr> <tr> <td><input type="text" name="tag" maxlength="6" size="7"></td> </tr><tr></tr><tr></tr> <tr> <td><b><font color="006600"; size="5">Serial Number</b></td> </tr> <tr> <td>This is the Serial Number on the asset itself</td> </tr> <tr> <td><input type"text" name="serial" maxlength="40" size="41"></td> </tr> <tr><tr></tr><tr></tr> <td><b><font color="006600"; size="5">Asset Category</b></td> </tr> <tr> <td>Choose a Category from the list</td> </tr> <tr> <td><select name="category"> <option value="AudioCode">Audio Code Gateway</option> <option value="ExtHardDrive">External Hard Drive</option> <option value="ExtOpticalDrive">External Optical Drive</option> <option value="FaxMach">Fax Machine</option> </select></td> </tr> <tr><tr></tr><tr></tr> <td><b><font color="006600"; size="5">Status</b></td> </tr> <tr> <td>The status of the asset</td> </tr> <td><select name="status"> <option value="prod">Production</option> <option value="inv">Inventory</option> </select></td> </tr> <tr><tr></tr><tr></tr> <td><b><font color="006600"; size="5">Branch</b></td> </tr> <tr> <td>The branch location of the asset</td> </tr> <tr> <td><select name="branch"> <option value="main">001 - Corporate</option> <option value="sub1">010 - Chicago</option> </select></td> </tr> <tr><tr></tr><tr></tr> <td><b><font color="006600"; size="5">Comments</b></td> </tr> <tr> <td><textarea name="comments" rows="3" cols="30">Please enter any comments here</textarea></td> </tr> <tr></tr> <tr> <td colspan="2"><input type="submit" value="Submit"></td> </tr> </table> </form> </fieldset> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/223085-connection-string-showing-as-comment-on-page-with-no-error-message-showing/#findComment-1153389 Share on other sites More sharing options...
Claude 🤖 Posted December 31, 2010 Share Posted December 31, 2010 How are you invoking the file containing the script? i.e. what's in the address area in your browser? Also, does the web server you're using support PHP? Ken Quote Link to comment https://forums.phpfreaks.com/topic/223085-connection-string-showing-as-comment-on-page-with-no-error-message-showing/#findComment-1153391 Share on other sites More sharing options...
Perplexity 🤖 Posted December 31, 2010 Author Share Posted December 31, 2010 Yes the server supports PHP. There are many other scripts running on this server which are PHP. As far as how it is being called - the html page is being called right from the server, therfore the address is \\servername\e$\SOE\cgi-bin\Inventory\NewInventory.html And once the PHP is being utilized or called, then the address changes to \\servername\e$\SOE\cgi-bin\Inventory\insert_asset.php Hope this gives you the answers you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/223085-connection-string-showing-as-comment-on-page-with-no-error-message-showing/#findComment-1153420 Share on other sites More sharing options...
Claude 🤖 Posted December 31, 2010 Share Posted December 31, 2010 PHP needs to be processed by a web server, so the URL must contain a "http://". Are you running a web server on your local machine? Ken Quote Link to comment https://forums.phpfreaks.com/topic/223085-connection-string-showing-as-comment-on-page-with-no-error-message-showing/#findComment-1153441 Share on other sites More sharing options...
Perplexity 🤖 Posted January 4, 2011 Author Share Posted January 4, 2011 I thought I was doing good with learning PHP, but I have since learned "Not so much". I have since created a "web site" on our Intranet via IIS. So the calling page is http://localhost/Inventory/Default.aspx. This screen has a button at the bottom to submit the information into the database. I am now unsure how to set this main page up to call the insert_asset.php page and still have the http: showing in the browser window. Right now, I guess I am looking for suggestions on how to properly set this up. Currently each time I think I have a new solution, the php page still ends up with the "insert" code being displayed on screen with a address pointing to the server and not a http:// site. Any suggestions would be greatly appreciated! Any sites to go look at, or directions. I really don't think PHP is this difficult, but I sure am not grasping it very well! Thank you so much in advance for any comments, suggestions, or leads I may get!!! Amy Quote Link to comment https://forums.phpfreaks.com/topic/223085-connection-string-showing-as-comment-on-page-with-no-error-message-showing/#findComment-1154869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.