Jump to content

boyyo

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by boyyo

  1. Whats wrong with this code ? <?php $dbc = mysqli_connect('localhost', 'boyyo_boyyo', 'KiaNNa11', 'boyyo_aliendatabase') or die('Error connecting to MySQL server.'); $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $email = $_POST['email']; $query = "INSERT INTO email_list (first_name, last_name, email) " . "VALUES ('$first_name', '$last)name', '$email')"; mysqli_query($dbc, $query ) or die('Error querying database.'); echo 'Customer added. ' ; mysqli_close($dbc); ?> I have no idea whats wrong with this code?
  2. when you say try returning the actual error message what do you mean by that?
  3. Im trying to connect to a database from php. Heres the code: <?php $dbc = mysqli_connect('192.168.0.122', 'boyyo', 'KiaNNa11', 'aliendatabase') or die('Error connecting to MySQL server.'); $query = "INSERT INTO aliens_abduction (first_name, last_name, " . "when_it_happened, how_long, how_many, alien_description, " . "what_they_did, fang_spotted, other, email) " . "VALUES ('Sally', 'Jones', '3 days ago', '1 day', 'four', " . "green with six tentacles', 'We just talked and played with a dog', " . "'yes', 'I may have seen your dog. Contact me.', " . "'sally@gregs-list.net')"; $result = mysqli_query($dbc, $query) or die('Error querying database.'); ?> I think i have a theory that my MySQL server location is wrong but i dont know. I use HostGator to do this and im using Phpmyadmin. But everytime i type in a form that i created it says Error querying database. Can someone tell me whats wrong with this code. Oh by the way im using head first into PHP and MySQL
  4. Ohhh!! So that code at the beggining: <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" /><br /> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" /><br /> <label for="email">What is your email address?</label> <input type="text" id="email" name="email" /><br /> <label for="whenithappened">When did it happen?</label> <input type="text" id="whenithappened" name="whenithappened" /><br /> <label for="howlong">How long were you gone?</label> <input type="text" id="howlong" name="howlong" /><br /> <label for="howmany">How many did you see?</label> <input type="text" id="howmany" name="howmany" /><br /> <label for="aliendescription">Describe them:</label> <input type="text" id="aliendescription" name="aliendescription" size="32" /><br /> <label for="whattheydid">What did they do to you?</label> <input type="text" id="whattheydid" name="whattheydid" size="32" /><br /> <label for="fangspotted">Have you seen my dog Fang?</label> Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" /> No <input id="fangspotted" name="fangspotted" type="radio" value="no" /><br /> <img src="fang.jpg" width="100" height="175" alt="My abducted dog Fang." /><br /> <label for="other">Anything else you want to add?</label> <textarea id="other" name="other"></textarea><br /> <input type="submit" value="Report Abduction" name="submit" /> </form> is the form. I thought you had to delete that and input the code that it says on the book and that would be the form! Ohhh wow im so dumb haha thanks for the help! I really appreciate it!
  5. i just started a book called head first php and mysql and i think the syntax in the book is wrong this is what i put: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Aliens Abducted Me - Report an Abduction</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h2>Aliens Abducted Me - Report an Abduction</h2> <?php $when_it_happened = $_POST['whenithappened']; $how_long = $_POST['howlong']; $alien_description = $_POST['description']; $fang_spotted = $_POST['fangspotted']; $email = $_POST['email']; echo 'Thanks for submitting the form.<br />'; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . '<br />'; echo 'Describe them: ' . $alien_description . '<br />'; echo 'Was Fang there? ' . $fang_spotted . '<br />'; echo 'Your email address is ' . $email; ?> </body> </html> I saved it as an html as the book says and this is what comes out: Aliens Abducted Me - Report an Abduction '; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . ' '; echo 'Describe them: ' . $alien_description . ' '; echo 'Was Fang there? ' . $fang_spotted . ' '; echo 'Your email address is ' . $email; ?> Is there a reason that it is putting that?Isnt it supposed to put out a form?Help Please!
×
×
  • 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.