SQL Murdered my Program!

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
OoZI
Posts: 109
Joined: Mon Jan 02, 2012 4:22 pm

SQL Murdered my Program!

Post 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
-OoZI

My Blog
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: SQL Murdered my Program!

Post 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.
The indelible lord of tl;dr
User avatar
OoZI
Posts: 109
Joined: Mon Jan 02, 2012 4:22 pm

Re: SQL Murdered my Program!

Post by OoZI »

I figured it out... I was querying the wrong database... Derp.
-OoZI

My Blog
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: SQL Murdered my Program!

Post by Jackolantern »

Hehe, been there before :D
The indelible lord of tl;dr
User avatar
OoZI
Posts: 109
Joined: Mon Jan 02, 2012 4:22 pm

Re: SQL Murdered my Program!

Post 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>";
-OoZI

My Blog
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: SQL Murdered my Program!

Post 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 ;)
The indelible lord of tl;dr
User avatar
OoZI
Posts: 109
Joined: Mon Jan 02, 2012 4:22 pm

Re: SQL Murdered my Program!

Post by OoZI »

Thanks! You get a cookie. :D
-OoZI

My Blog
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: SQL Murdered my Program!

Post by Jackolantern »

-munch munch munch- :D
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: SQL Murdered my Program!

Post by hallsofvallhalla »

Oh so SQL didn't murder your code! It was the butler with the candle stick in the broom closet!
Post Reply

Return to “Advanced Help and Support”