please help code prob after php 4 upgrade

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rponchek
Forum Newbie
Posts: 7
Joined: Sat Dec 28, 2002 10:33 pm

please help code prob after php 4 upgrade

Post 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
";
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post 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.
rponchek
Forum Newbie
Posts: 7
Joined: Sat Dec 28, 2002 10:33 pm

thanks

Post 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
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post 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...
rponchek
Forum Newbie
Posts: 7
Joined: Sat Dec 28, 2002 10:33 pm

fixed, but...

Post 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 {
Post Reply