GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-Jan-2005, 10:04
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road

Very New php/mysql


I must admit that I am treading foreign waters when working with mysql & php, but in researching many other errors that I have been receiving while "trying to correct some errors in the code below, I decide to register, as I am stumped.

Parse error: parse error, unexpected T_VARIABLE on line 47

is the most recent error that I am receiving, and I am not sure what to do. I have read several posts, and manuals, but I am lost. I do apologize for the, what is probably an elementary problem, but your help is most appreciated.
Here is the code:
PHP Code:

$result=mysql("$DBName","SELECT * FROM Category ORDER BY Category");
fontFace("Arial","Select a category:<br><br>");
echo "<ul>";   
while (($row=mysql_fetch_row($result)) 
//line 47 error is next line
$Cat=$row[0];
$CatID=$row[1];
fontFace("Arial","<li><a href='$Relative/items.php?CA=$CatID&UID=$UID'>$Cat</a></li>");
        }
echo "</ul>"; 


Last edited by JdS : 26-Jan-2005 at 10:25. Reason: did not insert php code correctly
  #2  
Old 26-Jan-2005, 10:25
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello phpnewbie,

It's simply a typo I think, you missed the (opening) curly bracket in the while() structure.

PLUS, you seem to have an extra (opening) bracket in this line: while (($row=mysql_fetch_row($result))
  #3  
Old 26-Jan-2005, 10:41
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road

different parse


Thanks You, I have corrected that one (I think) but I am now seeing

Parse error: parse error, unexpected $ on line 56

And the code stops at line 55, or at least that is how it looks.. Here is the code from line 46 to the end:

PHP Code:

{
while ($row=mysql_fetch_row($result)) 
$Cat=$row[0];
$CatID=$row[1];
fontFace("Arial","<li><a href='$Relative/items.php?CA=$CatID&UID=$UID'>$Cat</a></li>");
        
echo "</ul>";

commonFooter($Relative,$UID);
?> 


Again I apologize for my ignorance.... this is all a learning exerience for me.

Quote:
Originally Posted by JdS
Hello phpnewbie,

It's simply a typo I think, you missed the (opening) curly bracket in the while() structure.

PLUS, you seem to have an extra (opening) bracket in this line: while (($row=mysql_fetch_row($result))
  #4  
Old 26-Jan-2005, 10:59
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Try replacing that bit with this instead...

PHP Code:

<?

// comment this out ---> {
while ($row=mysql_fetch_row($result))
{
  $Cat=$row[0];
  $CatID=$row[1];
  fontFace("Arial","<li><a href='$Relative/items.php?CA=$CatID&UID=$UID'>$Cat</a></li>");
}
echo "</ul>";

commonFooter($Relative,$UID);
?>

  #5  
Old 26-Jan-2005, 12:32
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road
I have made the requested changes and a different group errors have displayed. Here are the errors that I am receiving, and my Code. Sorry about the length, I was trying NOT to post all of it, but I am stuck, I have read most of the MySql manual, but not know the intricacies of the program, I am not Quite sure what I'm looking for. ??:

Errors:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource on line 11

Warning: Cannot add header information - headers already sent by (output started at xx.php:11) on line 40


Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource on line 48


Here is the code starting at line 9
PHP Code:

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");
while ($row=mysql_fetch_row($result))
{
$CII=$row[0];
$CDa=$row[1];
$pieces=explode(":",$CDa);
$DCHK=$pieces[1];
if ($DCHK < $old) {
mysql("$DBName","DELETE FROM CartItems WHERE CartItemsID = '$CII'");
    }
}


if ($UID != "") {
$result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'");
$num=mysql_num_rows($result);
if ($num == "0") {
$dt=date("YmdHis");
$UID="$dt$REMOTE_ADDR";
$date=date("z");
mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
Header("Location: $PHP_SELF?UID=$UID");
}
}

if ($UID == "") {
$dt=date("YmdHis");
$UID="$dt$REMOTE_ADDR";
$date=date("z");
mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
Header("Location: $PHP_SELF?UID=$UID");
}
commonHeader("$Company","Select a category");

$result=mysql("$DBName","SELECT * FROM Category ORDER BY Category");
fontFace("Arial","Select a category:<br><br>");
echo "<ul>";
 
while ($row=mysql_fetch_row($result)) { 
  $Cat=$row[0]; 
  $CatID=$row[1]; 
  fontFace("Arial","<li><a href='$Relative/items.php?CA=$CatID&UID=$UID'>$Cat</a></li>"); 
} 
echo "</ul>"; 

commonFooter($Relative,$UID); 
?> 

  #6  
Old 28-Jan-2005, 14:29
firebird's Avatar
firebird firebird is offline
New Member
 
Join Date: Jan 2005
Posts: 11
firebird is on a distinguished road
By taking a quick look at your code, it seems to me that you should replace all mysql() with mysql_db_query.

So

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");

would become

$result=mysql_db_query("$DBName","SELECT CartItemsID,Date FROM CartItems");

etc.

Hope that's it,

Dave.
  #7  
Old 28-Jan-2005, 14:54
phpnewbie phpnewbie is offline
New Member
 
Join Date: Jan 2005
Posts: 10
phpnewbie is on a distinguished road
Thanks Dave, I have printed out your suggestion, but future use, but that doesn't seem to solve my issue. I started another thread, as this thread answered the 1st few questions I had. Thank you for your input

Quote:
Originally Posted by Dave
By taking a quick look at your code, it seems to me that you should replace all mysql() with mysql_db_query.

So

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");

would become

$result=mysql_db_query("$DBName","SELECT CartItemsID,Date FROM CartItems");

etc.

Hope that's it,

Dave.
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP/MySQL coding issue cmarti MySQL / PHP Forum 3 26-Jul-2004 08:01
Problem with php/mysql script during runtime norok MySQL / PHP Forum 3 25-Jun-2003 05:35
PHP/mySQL backend configuration help needed jrobbio Web Design Forum 2 17-Apr-2003 10:07
Tripod UK offering PHP/MySQL! roly Free Web Hosting 15 04-May-2002 03:46

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:31.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.