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
No output shown from PHP
Old 10-09-2010, 04:20 PM No output shown from PHP
Extreme Talker

Posts: 193
Name: Adam Moseley
Trades: 0
I have a html with a form pointing to a php file that is supposed to show values from the row which relates to the imput value from the form.

Below is the code I am using for the form:
PHP Code:
<form action="customer.php" method="get">
<
input type="text" name="reg" />
<
input type="submit" />
</
form
and the PHP file is:
PHP Code:
<?php
$host 
'localhost';
$user 'gahrefri_custom';
$pass 'password';
$dbname 'gahrefri_gahcustomer';
$tablename 'gahcustomer';
$con mysql_connect("$host","$user","$pass");
if (!
$con)
  {
  die(
'Could not connect... ' mysql_error());
  }
mysql_select_db("$dbname"$con);
$result mysql_query("SELECT * FROM $tablename
WHERE Reg No='reg'"
);
  {
  echo 
$row['Reg No'] . " " $row['Customer'] . " " $row['Contract'] . " " $row['Comments'];
  }
?>
The 'Reg No', 'Customer', 'Contract', and 'Comments', relates to the header of each column in the MySQL database.

Can anyone point firmly me in the right direction?
__________________

Please login or register to view this content. Registration is FREE
aadam is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-09-2010, 05:59 PM Re: No output shown from PHP
miki86's Avatar
Extreme Talker

Posts: 185
Location: print_r($serbia);
Trades: 0
PHP Code:
$result mysql_query("SELECT * FROM $tablename WHERE Reg No='reg'");
$row mysql_fetch_array($result); 
echo 
$row['Reg No'] . " " $row['Customer'] . " " $row['Contract'] . " " $row['Comments']; 

Last edited by miki86; 10-09-2010 at 06:02 PM..
miki86 is online now
Reply With Quote
View Public Profile
 
Old 10-09-2010, 06:27 PM Re: No output shown from PHP
Ultra Talker

Posts: 366
Name: Steve
Location: Miami, FL, Earth
Trades: 0
As above, but

$row = mysql_fetch_array($result);

should be

$row = mysql_fetch_assoc($result);

Otherwise, it will return an indexed array rather than an associative array (as is being used)
__________________
- Steve

President,
Please login or register to view this content. Registration is FREE
smoseley is offline
Reply With Quote
View Public Profile Visit smoseley's homepage!
 
Old 10-09-2010, 06:47 PM Re: No output shown from PHP
Extreme Talker

Posts: 193
Name: Adam Moseley
Trades: 0
Thanks for the help but the page now simply displays,

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home4/gahrefri/public_html/member/service/customer.php on line 20
__________________

Please login or register to view this content. Registration is FREE
aadam is offline
Reply With Quote
View Public Profile
 
Old 10-09-2010, 07:57 PM Re: No output shown from PHP
Skilled Talker

Posts: 52
Name: Alex
Trades: 0
Reg No
what is it?
elf2002 is offline
Reply With Quote
View Public Profile
 
Old 10-10-2010, 04:11 AM Re: No output shown from PHP
miki86's Avatar
Extreme Talker

Posts: 185
Location: print_r($serbia);
Trades: 0
Try this:
PHP Code:
$result mysql_query("SELECT * FROM '{$tablename}' WHERE Reg No='reg'"); 
$row mysql_fetch_assoc($result);  
echo 
$row['Reg No'] . " " $row['Customer'] . " " $row['Contract'] . " " $row['Comments']; 
miki86 is online now
Reply With Quote
View Public Profile
 
Old 10-10-2010, 07:10 AM Re: No output shown from PHP
Skilled Talker

Posts: 52
Name: Alex
Trades: 0
as I know, names of fields with spaces not allowed in mysql
(Reg No)?
elf2002 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to No output shown from PHP
 

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.24674 seconds with 12 queries