Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Help with Modification Issues (http://www.mysidiaadoptables.com/forum/showthread.php?t=5357)

Abronsyth 01-31-2017 08:52 PM

Help with Modification Issues
 
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 Code:

            $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?

IntoRain 01-31-2017 10:10 PM

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 Code:

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

$id $riddle->id;
$clue $riddle->clue;
$solve $riddle->solve


Abronsyth 02-01-2017 08:45 AM

Aaaah! Right!

Thank you so much!

Abronsyth 02-01-2017 09:55 AM

OK one more problem.

It's this chunk of code;

PHP Code:

$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:

IntoRain 02-01-2017 12:36 PM

I think the problem is with the syntax. Instead of

PHP Code:

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

Try

PHP Code:

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


Abronsyth 02-01-2017 07:29 PM

That seems to have done the trick, thank you!


All times are GMT -5. The time now is 05:08 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.