Get support from Xavier Media
It is currently Sun Dec 08, 2013 12:15 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Can someone check out this code and tell me whats wrong?
PostPosted: Sat Jul 10, 2010 4:48 am 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Fri Jul 09, 2010 2:59 am
Posts: 4
Points: 0
I wrote this as part of a PHP lesson I am doing. I cannot get it to work!! I have checked all of my server and database settings, everything seems to be in order. The Database username and password are correct. I have even re-written the snippet three times. Can someone tell me if the source code is outdated as to the reason it is not working? The PHP version running on my server is 4.3.1 and I am using phpMyAdmin as the tool. Any help would be greatly appreciated. Thanks in advance.


PHP Code:
<?php
$first_name=$_POST['firstname'];
$last_name=$_POST['lastname'];
$when_it_happened=$_POST['whenithappened'];
$how_long=$_POST['howlong'];
$how_many=$_POST['howmany'];
$alien_description=$_POST['aliendescription'];
$what_they_did=$_POST['whattheydid'];
$fang_spotted=$_POST['fangspotted'];
$email=$_POST['email'];
$other=$_POST['other'];

$dbc=mysqli_connect('mysql','username','password','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 ('$first_name', '$last_name', '$when_it_happened','$how_long','how_many',".
"'alien_description','$what_they_did','$fang_spotted','$other','$email')";

$result=mysqli_query($dbc,$query)
or die('Error querying database.');

mysqli_close($dbc);

echo 'Thanks for submitting the form.<br/>';
echo 'You were abducted'.$when_it_happened;
echo 'and were gone for'.$how_long.'<br/>';
echo 'Number of aliens:'.$how_many.'<br/>';
echo 'Describe them:'.$alien_description.'<br/>';
echo 'The aliens did this:'.$what_they_did'<br/>';
echo 'Was Fang there?'.$fang_spotted'<br/>';
echo 'Other Comments:'.$other'<br/>';
echo 'Your email address is:'$email;
?>


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
 Post subject: Re: Can someone check out this code and tell me whats wrong?
PostPosted: Tue Jul 13, 2010 7:25 am 
Offline
XavierForum.com Admin
XavierForum.com Admin
Super VIP Member
Super VIP Member
User avatar

Joined: Tue Mar 15, 2005 4:37 pm
Posts: 1082
Location: Sweden
Points: 1500
The code looks OK. Do you get any error messages or anything?

_________________
Xavier Media®
Join me at LinkedIn | Get your latest blog post in your signature you too


Report this post
Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Can someone check out this code and tell me whats wrong?
PostPosted: Sun Jul 25, 2010 2:51 am 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Fri Jul 09, 2010 2:59 am
Posts: 4
Points: 0
I actually figured it out. I wasn't getting any error codes, but the information wasn't showing up in my database. I'm not sure what I did wrong, but I re-wrote the code in a text editor and then copied it to my HTML application and it started working.
I do have a new issue, though. Is there a chance that, using PHP and MySQL, I can make the information from a website appear in my web pages? I do not have access to the other website's database. It's for a real estate website I am working on. The customer doesn't have access to any other the home listing databases, so I can't keep newly-listed homes or recently sold homes on her new website that I built her. Any ideas would be greatly appreciated. Thanks in advance. Sorry for the late reply, btw. Take care.


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Registered users: No registered users


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]