Page 1 of 1
please help code prob after php 4 upgrade
Posted: Sat Dec 28, 2002 10:33 pm
by rponchek
I am newbie to php, but, after upgrading php to 4 from 3 the following code gives me a syntax error... please help me in finding out why... you can email me or post reply here.. thanks in advance..
// Grab all data for this user
$query = "select * from contact, type
where contact_ID=$ID
and cat=type_ID
";
Posted: Sat Dec 28, 2002 10:53 pm
by evilcoder
Looks to me like you left out a nice little $. And also, what is contact, type. What are you tryinf to do there?
$query = "select * from contact, type // whats this type for?
where contact_ID ='$ID '
and cat='$type_ID'
Its good practice to quote your variables too.
thanks
Posted: Sat Dec 28, 2002 11:11 pm
by rponchek
thanks for helping... contact, and type are the sql database names the query is running from...
after your corrections, i get the following error..
Parse error: parse error, unexpected T_VARIABLE in /Users/roger/Sites/contacts/edit.php on line 79
Posted: Sat Dec 28, 2002 11:12 pm
by Elmseeker
evilcoder wrote:Looks to me like you left out a nice little $. And also, what is contact, type. What are you tryinf to do there?
$query = "select * from contact, type // whats this type for?
where contact_ID ='$ID '
and cat='$type_ID'
Its good practice to quote your variables too.
It looks to me like he's trying to query 2 fields at the same time, contact and type...can't be positive tho...
fixed, but...
Posted: Sat Dec 28, 2002 11:19 pm
by rponchek
thanks this fixed the syntax, but now it appears it is not quering the database appropriately... and i am getting the else statement on my page "There are no contacts with that record ID."
this is current...
// Grab all data for this user
$query = "SELECT * FROM contact, type
where contact_ID ='$ID'
and cat='$type_ID' ";
$result = mysql_query($query) or die ( mysql_error() );
$num_rows = mysql_num_rows($result);
if ($num_rows == 0 ) {
echo "There are no contacts with that record ID.";
} else {