Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP issue with classes
    text
    copied!<p>I am having a little problem with the following code:</p> <pre><code>&lt;?php class appointments { private $conn; function __construct($conn) { $this-&gt;conn = $conn; } function usercompany($uid) { return $this-&gt;conn-&gt;getone("SELECT company FROM signup WHERE UID = '".$uid."'"); } function hastemplate($uid) { return $this-&gt;conn-&gt;getone("SELECT COUNT(parentid) FROM appointments_templates WHERE parentid = '$uid'"); } function gettemplate($uid) { if($this-&gt;hastemplate($uid)){ return $this-&gt;conn-&gt;getrow("SELECT * FROM appointments_templates WHERE parentid = '" . $uid . "'"); } else { $appointment_template = 'This is a reminder to let you know that you have an appointment on {appointment} at '. $this-&gt;usercompany($uid); $sql = "INSERT INTO appointments_templates SET parentid = '" . $uid . "', content = '" . $appointment_template . "'"; $this-&gt;conn-&gt;execute($sql); return $this-&gt;gettemplate($uid); } } } ?&gt; </code></pre> <p>When I call <code>usercompany($uid)</code> by itself I get a correct result which is the users company. However when I call <code>gettemplate($uid)</code> the new template gets added to the database but without the results of <code>usercompany($uid)</code>. Am I doing something wrong?</p> <p><strong>Edit:</strong> Regarding the INSERT syntax: <a href="http://milov.nl/2836" rel="nofollow">http://milov.nl/2836</a></p> <p>To recap: <strong>Issue is not that its not getting added to the database</strong> but rather than getting inserted as "This is a reminder to let you know that you have an appointment on {appointment} at XYZ Inc." its getting added as "This is a reminder to let you know that you have an appointment on {appointment} at "</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload