Jump to content

nexro

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nexro's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Alright, next question. (trying to understand & eliminate possible problems) I once played with a MSAccess DB with Frontpage authoring. And I found that when submitting information into the Database, EVERY field needed to have content. Is it the same with MySQL? If I fill out the form, and leave some fields blank, would it still create a new row in the database filling in what content it could?
  2. Another question, in just trying to understand this. I'm basing this off a tutorial I found on the internet, and all the digging I've done says this should work. But while I understand most of the commands, I wonder.... What is the purpose of these? : [code] $Name=$_POST['Name']; [/code] I noticed that the $Name variable is the same both before and after this command is issued, so what is it doing?
  3. Yeah, I figured that one out. I was going to say I was a bit 'hasty' in that last post. Just kind of frustrated. But I've managed to connect to the database, read the entries which are there, so I know I'm connecting just fine. I've verified that the variables are being sent from my HTML page to the php script appropriately by having it echo the variables back to me. So it would seem, that the problem is back to the original one. And that's simply that [code] $query = "INSERT INTO contacts VALUES ('','$Name','$Company','','$Address1','$Address2','$City','$Province','$PostalCode', '$PhoneH','$PhoneW','$PhoneM','$Fax','$Email','$Website','$Comments')";[/code] Is not actually creating any new entries into the database. Is there a different way that this could be written that would create the same effect. Perhaps telling it which database field to put each of the variables into?
  4. Thank you, I overlooked that. But if I understand correctly, even WITHOUT the $'s it should have created a new row, it just would have used the words and not the variables. So I would have had an entry where the name was 'name' and the company was 'company'. But it still didn't add that row. I decided to play round with your comment on echoing things. And I'm really wondering if it is connecting to the database properly, even though I'm not getting the "unable to select database" error. So I tried this: [code] <? $host="db.doesntmatter.com"; $username="my_username"; $password="password"; $database="my_database"; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); echo "Connected to Database.<br>\n"; $query = "SELECT FROM contacts"; $result=mysql_query($query); echo "<b>$result<br>"; mysql_close(); ?>[/code] Should this not echo all of the results from the query with no organization to it? I mean, it SHOULD return me with something shouldn't it? (There are two rows in the database which I created through myphpadmin) All I get as a result from this, is a blank page that says, "Connected to Database." without showing me anything from the content of the mysql table.
  5. Alright, I'm completely new to php and this is the first script I've ever tried writing. In essence, it should be pretty simple.. I think?? Anyways, the purpose of the script (if it isn't obvious) is to post user information into a mysql database. I had recieved some syntax errors, which I fixed. And some 'cannot connect to server' errors which I also fixed. NOW, I log into my register.html page fillout the information, click submit and it loads my register.php script properly, and it doesn't show me any errors, just a blank screen. So I figured "hoorah!!! It's working!!!" Gleefully, I run off to my myphpadmin site and browse the database, to my dismay, there's no new row which has been added. SOOO, not knowing where to look next for the problem, I run to the net, find this site and post this message. So I hope somebody can help. Anyways, here's a copy of the script... (with a few changes to the top 4 lines *wink*) [code] <? $host="db.doesntmatter.com"; $username="my_username"; $password="mypassword"; $database="my_database"; $Name=$_POST['Name']; $Company=$_POST['Company']; $Address1=$_POST['Address1']; $Address2=$_POST['Address2']; $City=$_POST['City']; $Province=$_POST['Province']; $PostalCode=$_POST['PostalCode']; $PhoneH=$_POST['PhoneH']; $PhoneW=$POST['PhoneW']; $PhoneM=$_POST['PhoneM']; $Fax=$_POST['Fax']; $Email=$_POST['Email']; $Website=$_POST['Website']; $Comments=$_POST['Comments']; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO contacts VALUES ('','Name','Company','','Address1','Address2','City','Province','PostalCode', 'PhoneH','PhoneW','PhoneM','Fax','Email','Website','Comments')"; mysql_query($query); mysql_close(); ?> [/code]
×
×
  • 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.