Jump to content


Photo

Need help with displaying data from database!


  • Please log in to reply
29 replies to this topic

#21 xux

xux
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 06 October 2006 - 12:08 PM

tdw,
      this is becoming interesting,it returned the id but the email adresses were just blanks something like
Email Address of Subscribers
1
2
What do you think is wrong?Thanks
My Regards,
XUX


#22 xux

xux
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 06 October 2006 - 12:17 PM

Hi,
    This is the form am using to collect input from a form

<?php 
include('header1.tpl');
    $email=$HTTP_POST_VARS['email'];
    $email=trim($email);
   $email = addslashes($email);

  
 // open connection to MySQL server
$connection = mysql_pconnect('localhost', '', '') 
or die ('Unable to connect!');
// select database for use
mysql_select_db('DB') or die ('Unable to select database!');
 $query="insert into newsletter values (null, '$email')";
$result=mysql_query($query);
 if ($result)
echo'<br/>';
echo'<center>';
echo 'Thank you for signing up for ';
echo'</center>';


?>
</div>

<?php
include('footer.tpl');
?>
please HELP is Needed
Thanks

#23 thedarkwinter

thedarkwinter
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationLondon

Posted 06 October 2006 - 12:44 PM

... starting to make sense  :)

well, is id an auto_increment field?

the insert statement i would use would be

$query="INSERT INTO newsletter (email) VALUES ('$email')";

also, instead of
$HTTP_POST_VARS['email']
try
$_POST['email']
though i dont know whether that will make a difference.

also... you need brackets on the if ($result), cos at the moment it will be saying successful regardless of whether it worked or not.
if ($result)
{
echo'<br/>';
echo'<center>';
echo 'Thank you for signing up for ';
echo'</center>';
}

Remember - if you don't figure it out yourself, you'll probably forget it tomorrow :)

#24 xux

xux
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 09 October 2006 - 12:08 PM

Thanks,
          I have implemented the changes but it is still ouputting just numbers.I appreciate your assistance.Thanks
XUX

#25 xux

xux
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 09 October 2006 - 12:17 PM

Hi,
    Maybe I should drop the table and create another one,what do you think?The current table is auto increment,do you think it should be changed?Thanks men
My Regards,
XUX

#26 thedarkwinter

thedarkwinter
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationLondon

Posted 09 October 2006 - 04:05 PM

Hi

Well i dont think you need to drop the table... its best that it is auto_increment. Unless the datatype for email is not correct (should be varchar(255) or something of the sort).

I think maybe its not reading the email from post when its writing the data.

Trying doing a print_r($_POST) or print_r($HTTP_POST_VARS) to see if the post is being sent.

Also,
echo $query
just before you run the query to make sure its writing the correct thing.

Cheers,
tdw
Remember - if you don't figure it out yourself, you'll probably forget it tomorrow :)

#27 xux

xux
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 10 October 2006 - 10:11 AM

Ok, let me try dat out.
Thanks

#28 xux

xux
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 13 October 2006 - 05:45 PM

Hi,
    I am actually baffle cos the code is not yet working probably.What else do you think I can do?
My Regards
xux

#29 xux

xux
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts

Posted 14 October 2006 - 09:09 PM

Hi,
  Your help is still highly appreciated.Thanks

#30 thedarkwinter

thedarkwinter
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationLondon

Posted 19 October 2006 - 04:26 PM

hi

sorry, haven't been on for a while...

where is the code not working now? it seems not much is working at all :)

if you want to attach/email me the pages that aren't working i can have a better look at them...

cheers,
tdw
Remember - if you don't figure it out yourself, you'll probably forget it tomorrow :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users