Jump to content

hayes121

New Members
  • Posts

    6
  • Joined

  • Last visited

hayes121's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Last question I promise I have set up a seperate table in my data base called 'my_build', I am trying to insert new data into this table . I have written up what i though was the write code but i doesnt seem to be adding the data to the table, can you see any problems with the code? <?php $con = mysqli_connect("localhost", "root", "", "Computers"); if ( isset($_POST['serial_no']) && isset($_POST['description']) && isset($_POST['price']) && isset($_POST['fname']) && isset($_POST['lname']) ) { $s = mysql_real_escape_string($_POST['serial']); $d = mysql_real_escape_string($_POST['description']); $p = mysql_real_escape_string($_POST['price']); //$sql = "INSERT INTO `my_build` (Serial_no, Description, Price) //VALUES ('$s', '$d', '$p')"; echo "<pre>\n$sql\n</pre>\n"; mysqli_query($con, "INSTER INTO `my_build` (serial_no, description, price) VALUES ('$s', '$d', '$p')"); echo 'Success - <a href="home.php">Continue...</a>'; return; } mysqli_close($con); ?> <p>Add A New User</p> <form method="post"> <p>Serial_no: <input type="text" name="serial_no"></p> <p>Description: <input type="text" name="description"></p> <p>Price: <input type="text" name="price"></p> <p><input type="submit" value="Add New"/> <a href="home.php">Cancel</a></p> </form>
  2. sorry i didnt mean to offend in asking you to do it for me was just looking to see how it is done and to have an example, really appricate all the help you have given me though! Thanks
  3. sorry for all the questions and thanks a million for the help! Is there a way to convert html to php? or do i just need to change the tags? for example i have attached my 'parts' page (.html) and then some simple php code to print out a table from my data base. Would you be able to join the two of these for me and re upload it? Login.html test.php
  4. Thanks for the feedback guys!!! When you say the 'named indexes' does that mean the column names that i have set in the table myself? Also another question with regards php and databases. I want to add a login in function to the site, I have all the html code for the site done and the php login file, but do i need to combine the two files to a .html file or a .php file? Or do i leave them seperate and reference the .php login from the html?
  5. Hi guys i am new here and new to mysql, I am having some trouble reading data from my table. When ever i run my code i get the following error: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /Applications/XAMPP/xamppfiles/htdocs/lab9.php on line 8 How can i fix this i have tried all that i know and nothing is working, here is the code i am using Any help will be greatly appricated! <html> <head> <title></title> <?php $con = mysqli_connect("localhost", "root", "", "testTable"); echo '<table border="1">'."\n"; $result = mysqli_query($con, "SELECT * FROM table"); while ( $row = mysqli_fetch_array($result)) { echo("</tr><td>"); echo(htmlentities($row[0])); echo("</td><td>"); echo(htmlentities($row[1])); echo("</td><td>"); echo(htmlentities($row[2])); echo("</td><td>"); echo('<a href="edit.php?id=' .htmlentities($row[0]).' ">Edit</a> /'); echo('<a href="delete.php?id=' .htmlentities($row[0]).' ">Delete</a> '); echo("</td></tr>\n"); } mysqli_close($con); ?>
×
×
  • 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.