Jump to content

Archived

This topic is now archived and is closed to further replies.

tensionx

Strange

Recommended Posts

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
[b]"Parse error: syntax error, unexpected $end in /home/wekillmo/public_html/tablemaker.php on line 37"[/b]
[code]
<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>
[/code]

Share this post


Link to post
Share on other sites
billyBob i guess you mean also taking out the !
[code]if( $db = @mysql_connect("localhost", "name", "password") ) {
mysql_select_db("XXX",$db) or die("Select DB Error: ".mysql_error());
exit();
}[/code]

Share this post


Link to post
Share on other sites
I started doing PHP yesterday
Excuse the syntax :)
I come from ASP and am not tooo comfortable in this world yet.

Share this post


Link to post
Share on other sites
nvm i thought that was the connect srry :) my bad i will delete taht post :)  ;D

Share this post


Link to post
Share on other sites
Well. Took out the extra {
Now its saying

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

lol...

my select is really simple

select * from XXXX

I just need a damn excel style table...


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

Share this post


Link to post
Share on other sites
now it's telling you there's something wrong with the query. what's your query?

Share this post


Link to post
Share on other sites
$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

Share this post


Link to post
Share on other sites
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:

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

Then you'll know just why the query failed.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.