Jump to content

Strange


tensionx

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]
Link to comment
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");
Link to comment
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

Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.