Jump to content


Photo

Strange


  • Please log in to reply
9 replies to this topic

#1 tensionx

tensionx
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 August 2006 - 09:11 PM

I broke this down and tested each section.
Somehow i am missing something in the last line of my code.
I could use some helping eyes.
Here is my error
"Parse error: syntax error, unexpected $end in /home/wekillmo/public_html/tablemaker.php on line 37"
<html> 
<table border="0" CELLSPACING="0" CELLPADDING="10" align="center"> 

<?php 
//db connect and select 
$db = @mysql_connect("localhost", "XXX", "XXX"); 
if( ! ($db = @mysql_connect("localhost", "name", "password")) ) { 
} else { 
mysql_select_db("XXX",$db) or die("Select DB Error: ".mysql_error()); 
} 
$result=mysql_query ("SELECT * FROM XXX"); 

$count = 1; 
$column = 1; 
//loop statement 
while($myrow = mysql_fetch_array($result)) {

{ 
// first column display 
if ($column == 1) 
{ 

//field is the column in your table 
printf("<tr><td>%s</td>",$myrow["name"]); 
} 

else{ 
//second column display   
printf("<td>%s</td></tr>",$myrow["class"]); 
} 
$count += 1; 
$column = $count % 2; 
} 
?> 

</table>
</html> 


#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 August 2006 - 09:15 PM

why do you have an extra { after the while clause??
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 August 2006 - 09:17 PM

billyBob i guess you mean also taking out the !
if( $db = @mysql_connect("localhost", "name", "password") ) { 
mysql_select_db("XXX",$db) or die("Select DB Error: ".mysql_error()); 
exit();
}

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#4 tensionx

tensionx
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 August 2006 - 09:18 PM

I started doing PHP yesterday
Excuse the syntax :)
I come from ASP and am not tooo comfortable in this world yet.

#5 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 02 August 2006 - 09:19 PM

nvm i thought that was the connect srry :) my bad i will delete taht post :)  ;D

#6 tensionx

tensionx
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 August 2006 - 09:27 PM

Well. Took out the extra {
Now its saying

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/wekillmo/public_html/tablemaker.php on line 20"


lol...

my select is really simple

select * from XXXX

I just need a damn excel style table...


$result=mysql_query ("SELECT * FROM XXX");

#7 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 August 2006 - 09:30 PM

now it's telling you there's something wrong with the query. what's your query?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#8 tensionx

tensionx
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 August 2006 - 09:33 PM

$result=mysql_query ("SELECT * FROM XXX");
when i throw a  {
at the end
It stops giving me that error.
Then it sends me on my merry way to line 32. The last line... "</html>"
and says

Parse error: syntax error, unexpected $end in /home/wekillmo/public_html/tablemaker.php on line 32



#9 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 02 August 2006 - 09:52 PM

Can we please see the complete code (with the changes and unchanges you've made as suggested in this thread).

But before you do, reformat your code and indent the loops so you can see exactly what loops are open and that they are properly closed in sequence.

You can't just arbitrarily throw in unmatched curly braces.

The sensible was to debug is always to report the error and the query used that generated it.  For example:

$query = "SELECT * FROM table_name";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);

Then you'll know just why the query failed.
Legend has it that reading the manual never killed anyone.
My site

#10 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 August 2006 - 10:14 PM

are you really throwing in XXX as the table name????
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users