Jump to content

Problem inserting PHP code into a MySQL db (joomla)


eviktore

Recommended Posts

Hi,

 

The subject might be confusing. The thing I am trying to do is that I want to create a new row in a MySQL database, and in one of the fields I want to insert some PHP code. So that i can request that field from a browser and show the result of the code.

 

The problem is that when I try to create this database entry with a php statement the variables in the code to be inserted are handled as variables in the statement trying to insert in the database. The challenge is hence to write the varibles as plain text, while they still will be regognized as variables when i request the script later. The MySQL database is actually a joomla site and the code is supposed to be the introtext of an article in jos_content.

 

The code I want to insert is the following:

 

 

<?php

// These variables are picked up by the script that is inserting
$id = explode(":", $_GET['id']);
$bo = $id['1'];


// I select the different properties from another database
$result = mysql_query("SELECT * FROM oversikt WHERE id='$bo'") or die(mysql_error());
$row = mysql_fetch_array($result);


?>
<head>


</head>
<body>
<ul>
<li>Header 1 
<ul id='he1'>
<li>Sub1: <?php echo $row['s1']; ?></li>
<li>Sub 2: <?php echo $row['s2t']; ?></li>
<li>Sub3: <?php echo $row['s3']; ?></li>
<li>Mark:
<?php 

if ($row['s4']==1) echo "Yes"; else echo "No";
?>
</li>
</ul>
</li>

</ul>
</body>

 

 

Any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.