Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-14-2008, 10:57 PM New at this...
Junior Talker

Posts: 2
Trades: 0
Ok... i'm just getting started on PHP... and i tried to make my own signup form.. and if anybody could tell me what this error is at the bottom of the form, i'd be greatly appreciative!

no1saraefan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-15-2008, 02:57 AM Re: New at this...
Super Talker

Posts: 102
Trades: 0
Give me your signup.php code and I can help.
Aaron™ is offline
Reply With Quote
View Public Profile
 
Old 11-15-2008, 07:17 AM Re: New at this...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You would hardly need the code to tell that the MySQL server the OP tried to connect to doesn't exist.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-15-2008, 01:16 PM Re: New at this...
Super Talker

Posts: 102
Trades: 0
Well if he is new how would he know what to change, I hardly know anything about PHP when I was new, I got spoon fed for the 1st like 2 months.
Aaron™ is offline
Reply With Quote
View Public Profile
 
Old 11-15-2008, 01:45 PM Re: New at this...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Well before even looking at code, it would be advisable to find out whether the OP actually has MySQL available on localhost
because that error usually indicates that it ISN'T!!
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-15-2008, 04:08 PM Re: New at this...
Junior Talker

Posts: 2
Trades: 0
Quote:
Originally Posted by Aaron™ View Post
Give me your signup.php code and I can help.
The whole page quote is:
(I did put my login info where it says, except for localhost, which i think is what i need to leave it as...
Code:
<html>
<head>
<title>Sign Up for an Account with White Hill Church!</title>
</head>
<body bgcolor="#3333ff">
<font face="tahoma" color="yellow" size="+1">Welcome to WhiteHillChurch.com!</font><br><br>
<font face="tahoma" color="yellow">Sign up Here:
<br>
<form action="http://www.whitehillchurch.com/php/insert.php" method="post">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Phone: <input type="text" name="phone"><br>
Mobile: <input type="text" name="mobile"><br>
Fax: <input type="text" name="fax"><br>
E-mail: <input type="text" name="email"><br>
Web: <input type="text" name="web"><br>
<input type="Submit">
</form>
<?
$username="username";
$password="password";
$database="database";

mysql_connect(localhost,$username,$password);
@mysql_select_db($ID) or die( "Unable to select database");
$query="SELECT * FROM contacts";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Database Output</center></b><br><br>";

$i=0;
while ($i < $num) {

$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");

echo "<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>";

$i++;
}

?>
</body>
</html>
no1saraefan is offline
Reply With Quote
View Public Profile
 
Old 11-15-2008, 04:41 PM Re: New at this...
Super Talker

Posts: 102
Trades: 0
Should be an easy fix, changed the $ID to $database... if it still doesn't work then I am too tired to help you out.
PHP Code:
@mysql_select_db($database) or die(""); 
Aaron™ is offline
Reply With Quote
View Public Profile
 
Old 11-17-2008, 05:49 PM Re: New at this...
gmcalp's Avatar
Novice Talker

Posts: 8
Name: Geoff
Trades: 0
I know on my host I can't use 'localhost' for the MySQL server name, I have to put in a valid host name (ex: mysql.yourdomain.com), you may be in that same boat.
gmcalp is offline
Reply With Quote
View Public Profile
 
Old 11-19-2008, 12:30 AM Re: New at this...
Extreme Talker

Posts: 246
Trades: 3
On my host I can use 'localhost' , but for it to work, you need to add quotes around it. So, change:
Code:
mysql_connect(localhost,$username,$password);
to
Code:
mysql_connect('localhost',$username,$password);
Edit:Er, I guess PHP would still handle it correctly, but I would still pass it as a string, in either single or double quotes, just because it seems to be better practice.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by CouponGuy; 11-19-2008 at 12:38 AM..
CouponGuy is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 11:18 AM Re: New at this...
Super Talker

Posts: 102
Trades: 0
It was the database he was trying to connect too becuase he has it set to "$ID" instead of "$database" as he has as a variable.

Last edited by Aaron™; 11-21-2008 at 11:22 AM..
Aaron™ is offline
Reply With Quote
View Public Profile
 
Old 11-25-2008, 02:26 PM Re: New at this...
Junior Talker

Posts: 4
Name: Len
Trades: 0
I assume you are putting valid username and password data into the correct variables?????
drakon is offline
Reply With Quote
View Public Profile
 
Old 11-26-2008, 10:07 AM Re: New at this...
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
So try this (Culmination form others)

PHP Code:

$username
="username";
$password="password";
$database="database";
$server "localhost";

mysql_connect($server,$username,$password);
mysql_select_db($database) or die( "Unable to select database"); 
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to New at this...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35278 seconds with 12 queries