Jump to content

Recommended Posts

Hey, I'm having a few problems with a forum script. It's doing exactly what it should be doing but is

 

returning a few errors.

 

Script:

{
$sql = "SELECT primary_group
FROM users
WHERE user_id = ". $forums[$i]['last_post_user_id'] ."
";
$result = $db->query($sql);
while($row = $db->fetch_assoc($result))
{
	$last_post_group_id[] = $row;
}
}			
{
$sql = "SELECT group_colour
	FROM groups
	WHERE group_id = ". $last_post_group_id[0]['primary_group'] ."
";
$result = $db->query($sql);
while($row = $db->fetch_assoc($result))
{
$newest_poster_colour[] = $row;
}
}

 

It would appear to me that following errors are unjustified as the variables mentioned are defined

 

above and the SQL queries would seem to be fine. Note that the variable '$i' varies the offset

 

depending on what forum is being used.

 

Errors:

[Notice] Undefined variable: last_post_group_id (Line 199, File functions_forum.php)

SELECT group_colour FROM groups WHERE group_id =

Database Error

 

Array

(

    [MSG] => You have an error in your SQL syntax; check the manual that corresponds to your

 

MySQL server version for the right syntax to use near '' at line 3

    [NUM] => 1064

)

 

[Notice] Undefined variable: newest_poster_colour (Line 227, File functions_forum.php)

 

[Notice] Undefined offset: 5 (Line 199, File functions_forum.php)

SELECT group_colour FROM groups WHERE group_id =

Database Error

 

Array

(

    [MSG] => You have an error in your SQL syntax; check the manual that corresponds to your

 

MySQL server version for the right syntax to use near '' at line 3

    [NUM] => 1064

)

 

[Notice] Undefined offset: 5 (Line 227, File functions_forum.php)

 

[Notice] Undefined offset: 7 (Line 199, File functions_forum.php)

SELECT group_colour FROM groups WHERE group_id =

Database Error

 

Array

(

    [MSG] => You have an error in your SQL syntax; check the manual that corresponds to your

 

MySQL server version for the right syntax to use near '' at line 3

    [NUM] => 1064

)

 

[Notice] Undefined offset: 7 (Line 227, File functions_forum.php)

 

[Notice] Undefined offset: 8 (Line 199, File functions_forum.php)

SELECT group_colour FROM groups WHERE group_id =

Database Error

 

Array

(

    [MSG] => You have an error in your SQL syntax; check the manual that corresponds to your

 

MySQL server version for the right syntax to use near '' at line 3

    [NUM] => 1064

)

 

[Notice] Undefined offset: 8 (Line 227, File functions_forum.php)

 

[Notice] Undefined offset: 9 (Line 199, File functions_forum.php)

SELECT group_colour FROM groups WHERE group_id =

Database Error

 

Array

(

    [MSG] => You have an error in your SQL syntax; check the manual that corresponds to your

 

MySQL server version for the right syntax to use near '' at line 3

    [NUM] => 1064

)

 

[Notice] Undefined offset: 9 (Line 227, File functions_forum.php)

 

[Notice] Undefined offset: 10 (Line 199, File functions_forum.php)

SELECT group_colour FROM groups WHERE group_id =

Database Error

 

Array

(

    [MSG] => You have an error in your SQL syntax; check the manual that corresponds to your

 

MySQL server version for the right syntax to use near '' at line 3

    [NUM] => 1064

)

 

Notice] Undefined offset: 10 (Line 227, File functions_forum.php)

 

Notice] Undefined offset: 11 (Line 199, File functions_forum.php)

SELECT group_colour FROM groups WHERE group_id =

Database Error

 

Array

(

    [MSG] => You have an error in your SQL syntax; check the manual that corresponds to your

 

MySQL server version for the right syntax to use near '' at line 3

    [NUM] => 1064

)

 

Notice] Undefined offset: 11 (Line 227, File functions_forum.php)

 

If you can, please help me get rid of the errors.

 

Thank you,

Peter

Link to comment
https://forums.phpfreaks.com/topic/116723-solved-unjustified-errors/
Share on other sites

so...even though your query works fine and you're getting your desired results, you somehow think the problem is with your query string? If those sql errors were real, I assure you, you wouldn't be getting your desired results and things would not be working fine.

 

Therefore, either your problem is your error reporting system, or else possibly you have some erroneous call(s) to that function, include(s), etc.. or w/e, where vars aren't being set, etc... in addition to your normal calls where the vars are set, etc... that could cause you to have errors and yet at the same time, have results.

 

Because I promise you, if there's an error in your syntax, you don't get a result source returned. You get a false.

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.