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
https://forums.phpfreaks.com/topic/16375-strange/
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
https://forums.phpfreaks.com/topic/16375-strange/#findComment-68124
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
https://forums.phpfreaks.com/topic/16375-strange/#findComment-68146
Share on other sites

Archived

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

×
×
  • 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.