Page 1 of 1

SQL Murdered my Program!

Posted: Mon Nov 12, 2012 6:12 pm
by OoZI
First, My Code:

Code: Select all

include 'config.php';

echo "<center><h1><u>Support</u></h1></center";
echo "<ul>";
echo "<li><a href='/" . $siteIndex . "/usrmng/main.php?cmd=supportSubmit'>Submit a Ticket</a></li>";

$qTe = "SELECT * FROM tickets ORDER BY date_create";
$gTe = mysql_query($qTe) or die("Database Failure!");

while($row = mysql_fetch_assoc($gTe))
		{
		$id=$row['id'];
			echo '<tr>';
				echo '<td class="leftpart">';
					echo $row['subject'];
				echo '</td>';
				echo '<td class="rightpart">';
							echo $row['priority'];
				echo '</td>';
			echo '</tr>';
		}


My code keeps dying out at the "or die" part. Without "or die", I get this error:

Code: Select all

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\NewGame\usrmng\functions.php on line 317
What the heck is wrong with my SQL? I will give a cookie to the first person to figure it out. :D

Re: SQL Murdered my Program!

Posted: Tue Nov 13, 2012 1:43 am
by Jackolantern
That error means your query is returning an error. It is saying you have a boolean (true/false) because mysql_query() returns FALSE when it has an error (not the best system for sure).

Your query is fairly simple. Why don't you try copying the query text, and run it in phpMyAdmin on the SQL tab. See if it returns what you are expecting.

Re: SQL Murdered my Program!

Posted: Tue Nov 13, 2012 1:45 am
by OoZI
I figured it out... I was querying the wrong database... Derp.

Re: SQL Murdered my Program!

Posted: Tue Nov 13, 2012 1:46 am
by Jackolantern
Hehe, been there before :D

Re: SQL Murdered my Program!

Posted: Tue Nov 13, 2012 1:48 am
by OoZI
Here's my next problem, because I don't wanna open a new topic:

syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\wamp\www\NewGame\usrmng\functions.php on line 324


For this line of code:

Code: Select all

echo "<div style='background-color:" $row['color'] . "'>" . $row['priority'] . "</div>";

Re: SQL Murdered my Program!

Posted: Tue Nov 13, 2012 2:05 am
by Jackolantern
You forgot the period between 'background-color:" and $row['color']. It should be:

Code: Select all

echo "<div style='background-color:" . $row['color'] . "'>" . $row['priority'] . "</div>"; 
It tripped up the parser ;)

Re: SQL Murdered my Program!

Posted: Tue Nov 13, 2012 2:26 am
by OoZI
Thanks! You get a cookie. :D

Re: SQL Murdered my Program!

Posted: Tue Nov 13, 2012 4:19 am
by Jackolantern
-munch munch munch- :D

Re: SQL Murdered my Program!

Posted: Thu Nov 22, 2012 2:33 pm
by hallsofvallhalla
Oh so SQL didn't murder your code! It was the butler with the candle stick in the broom closet!