Help with Modification Issues

Forum
Last Post
Threads / Messages

Abronsyth

A Headache Embodied
Member
Joined
Aug 25, 2011
Messages
1,012
Points
36
Location
NY
Mysidian Dollar
73,285
Hey all, me again!

I am working on a riddle system that will quickly allow admins to create riddles, activate one at a time, and then users can answer them and get a reward once each (per riddle).

However I am getting the most obnoxious error:
Parse error: syntax error, unexpected '=' in /home/inekelmy/public_html/view/riddleview.php on line 29

Here is the code it's referring to:
PHP:
        	$id = $mysidia->db->select("riddle", array("id"), ("name" = $mysidia->input->post("currname")))->fetchColumn();
        	$clue = $mysidia->db->select("riddle", array("clue"), ("name" = $mysidia->input->post("currname")))->fetchColumn();
        	$solve = $mysidia->db->select("riddle", array("solve"), ("name" = $mysidia->input->post("currname")))->fetchColumn();

Does anyone see where I'm messing things up?
 
The entire "where" part of the query has to be inside the quotation marks. Also, you can fetch everything at once rather than making multiple calls to the database

PHP:
$riddle = $mysidia->db->select("riddle", array("id", "clue", "solve"), "name = '{$mysidia->input->post('currname')}'")->fetchObject();

$id = $riddle->id;
$clue = $riddle->clue;
$solve = $riddle->solve;
 
OK one more problem.

It's this chunk of code;

PHP:
$done = $mysidia->db->select("solved_riddles", array("name", "uid"), "name = '{$active}'", "uid = '$mysidia->user->uid'")->fetchColumn();
	if($done){...}
        else{...}

It is not doing what it is supposed to do. It is showing me the if{} content regardless of whether the uid+name are added to the table or not. The code simply adds a new row whenever someone solves a riddle, it records the riddle name and the user ID. This part is fully functioning.

The if{} statement is supposed to make it so that users who have solved see the if{} content, and users who have not see the else{} content.

If someone could point out my error here I'd be mighty thankful...and then I could run through some more tests and release the damn thing as a mod :colonu:
 
Last edited:
I think the problem is with the syntax. Instead of

PHP:
"name = '{$active}'", "uid = '$mysidia->user->uid'")->fetchColumn();

Try

PHP:
"name = '{$active}' and uid = '{$mysidia->user->uid}'")->fetchObject();
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top