PHP List Plugin not working...

Status
Not open for further replies.

slickorange

New Member
Hi there,

I am quite new to Fabrik but I do have a bit of experience with MySQL and a little with PHP.

I have searched the forums and followed advice, but nothing I do works.

I am simply trying to update a field using a SQL query when the PHP button is clicked in the list view.

I don't think the problem is in my code, I have tried very simple code and I have used examples from this forums. It is as if the PHP code simply does not execute I have even added syntax errors to the code on purpose but I do not even receive an error message.

Is there something I am missing?

Help would be greatly appreciated!
 
Bear in mind that you won't necessarily see any error messages, as (iirc) there's an implicit redirect, so the browser won't see direct output from your script.

So post you code here.

-- hugh
 
See screenshot of settings attached.

That is not my real code, it is a simpler form of what I am trying to achieve. It is not working... Like I said, it seems as if the code is not executing at all, I have tried multiple different codes.. nothing is working.
 

Attachments

  • settings.jpg
    settings.jpg
    42.2 KB · Views: 453
Never use the <?php tags in fabrik code fields.

You can always include a
exit;
in your code to see if it's running.
 
Ok, I have disabled ajaxify and when I put the exit; command I get a blank screen. So I suppose the code is in fact running, but I am seeing no changes being made in my database.

How can I see more debug information to try and figure out why the query is not executing?

*UPDATE* Seems I should not have used the double quotes... I removed all the single quotes and replaced the double quotes with single qoutes. That somehow did the trick...
 
The double quotes are not the problem, it was the single quote around 'group_id': table and column names need ` (or nothing)
 
Hello,

I run into a similar problem. The PHP code in PHP list plugin doesn't seem to work. Nothing is inserted into MySQL. The MySQL runs correctly in PHPmyadmin.
Here is the code. Fabrik reports normal completion of PHP code but as I said the dbase is not updated. I suspect that something is not interpreted correctly in the plug in but i can't figure what.
Is there a clue?


Code:
$user = JFactory::getUser();

$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "mydb";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO mytable (myfield, jid) SELECT  myfield, $user  FROM mytable.myfield WHERE jid = 0" ;


if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top