Hi there...I'm pretty new at the PHP game, I've basically taught myself everything from looking at examples scripts and Google, and I've only been tinkering with scripts for about a week. Therefore, I'm confused about the error I'm getting when I try and run this part of the script. Basically, I'm trying to update a record in a database through an html form, but it's failing to load the data from the database...so here's hoping for some help. The specific error the web browser has in it when I run the script is an unexpected T_STRING error. First Name Last Name, etc. are the fields in the database. Thanks in advance!

code:

echo "User Authenticated<br>";

mysql_connect($hostname,$db_name,$pwd);
@mysql_select_db($db_name) or die( "Unable to select database");

$query="SELECT * FROM members WHERE id='$idnum'";
$result=mysql_query($query);
$row = mysql_fetch_object($result);


$first = $row->First Name;
$last = $row->Last Name;
$femail = $row->Father's Email;
$r_state = $row->Return State/Zip;

$first = $row->First Name;
$last = $row->Last Name;
$femail = $row->Father's Email;
$r_state = $row->Return State/Zip;

umm. No, though PHP is nice it doesn't speak english. No spaces in variable names, you can't use the descriptions and definitely no quotes in them.
You have to use the field names so if the name for the First Name field was fname then you'd do $row->fname

$r_state = $row->Return State/Zip;

... what is that supposed to do? I'm going to guess you want it to give you something like "New York/15555" but that's not how return works.
You'd have to do something like

$r_state = $row->state . "/" . $row->zip;

It gave you the T_STRING error because when you used that quote for Father's Email it thought you were starting a string.

Hmmm, ok, I got the part about the variable names, but the problem is those ARE the field names in the database....that's where I was confused....so I should then change the field names in the database so that there are no spaces, quotes, etc? Or is there a way to specify that those are the field names?

I'm not sure how it even remotely allowed you to have spaces and quotes in a field name since it would break a query required to make it. Do a little research on database design.

Mainly, research what normalization is.

OK will do, thanks for the help and advice, I appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.