Jump to content

Melon Fresh

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Melon Fresh's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you sasa & obsidian all it working now :)
  2. Sorry for the late reply, yes you are right. What I am trying to do is draw variables from the mysql database e.g. $userid if you use echo mysql shows $userid but I know there is a way to show 1 (as the $userid = 1) thats what I was hoping eval would do, I have tried it many times but no response; here is my latest code and error [code=php:0] $result = @mysql_query("SELECT `code` FROM `tech_templates` WHERE `tid` = 13"); while($row = mysql_fetch_array($result))     { $new_page = eval($row['code']); echo "$new_page"; } [/code] The error is [b] Parse error: syntax error, unexpected '<' in /home/*****/public_html/****/access_control/index.php(23) : eval()'d code on line 1[/b] Here is what is in the database [code] <a href="index.php?logout=$userid" target="_parent" >Logout $usernameid </a> [/code]
  3. What I am trying to do is use variables in mysql, and eval i was told was the way to go, this is the whole code of the page [code] <?php include ("global.php"); if (isset($_COOKIE["bgauth"])){ } else { header("Location: login.php"); exit; } $result = @mysql_query("SELECT * FROM `tech_templates` WHERE `tid` = 5"); if (!$result) {   exit('<p>Error performing query: ' .       mysql_error() . '</p>'); } while($row = mysql_fetch_array($result))     {         $code5 = $row['code']; eval("\$code5 = \"$code5\";"); } ?> [/code]
  4. Sorry for putting it in the wrong place, and here is the code that gives me the error [code] <?php $result = @mysql_query("SELECT * FROM `tech_templates` WHERE `tid` = 5"); if (!$result) {   exit('<p>Error performing query: ' .       mysql_error() . '</p>'); } while($row = mysql_fetch_array($result))     {         $code5 = $row['code']; eval("\$code5 = \"$code5\";"); } ?> the error is [b]Parse error: syntax error, unexpected T_STRING in /******/******/public_html/index.php(30) : eval()'d code on line 4[/b] [/code]
  5. I am trying to learn how to use variables in mysql, and eval is what I need, the only problem is I don't get it, and when I have tried I always have error, so help please :) Here is the code that I want eval to work for,at the moment it has echo, but I need eval. ------------------------------------------------------ [code=php:0] $result = @mysql_query("SELECT * FROM `tech_templates` WHERE `tid` = 5"); if (!$result) {   exit('<p>Error performing query: ' .       mysql_error() . '</p>'); } while($row = mysql_fetch_array($result))     {         $code5 = $row['code']; echo ("$code5"); } [/code] ------------------------------------------------------ Any thoughts?
  6. It does not seem to work, I made a new table to try and test it but nothing, so here is the whole code and the sql from mysql Here is the code for the page test.php [code] <center><form action="" method="post" name="blogform" id="blogform" onsubmit="return checkForm();">   <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">   <tr>     <td bgcolor="#E0E9F2"> <table width="100%" border="0" cellspacing="0" cellpadding="2">       <tr>         <td width="10%">&nbsp;Answer: </td>         <td width="90%"><input name="for" type="radio" value="yes" checked="checked"/>         Yes           <input name="for" type="radio" value="no" />           No</td>       </tr>       <tr>         <td>&nbsp;Name:</td>         <td><input type="textfield" name="name" /></td>       </tr>     <tr>         <td>&nbsp;tests:</td>         <td><input type="checkbox" name="test[]" value="sims2" /> Sims 2   <input type="checkbox" name="test[]" value="sims3" /> Sims 3 <input type="checkbox" name="test[]" value="sims4" /> Sims 4 </td>       </tr>     </table></td>   </tr>   <tr>     <td bgcolor="#E0E9F2"><p><input name="checkp" type="submit" value="Add check" action".$_SERVER['REQUEST_URI']"/>       <p></td>   </tr> </form></center> [/code] [code=php:0] if(isset($_POST['checkp'])) { foreach ($_POST['test'] as $expan) { $test33 .= $expan.' '; } $test33 = trim($test33); $test33 = str_replace(' ',', ', $test33); $addtest = "insert into test values ('','$_POST[name]','$test33','$_POST[for]')";     mysql_query($addtest, $ServerConnect) or die(mysql_error()); } [/code] Here is the sql [code] CREATE TABLE `test` (   `tid` int(11) NOT NULL auto_increment,   `name` varchar(150) default NULL,   `test` set('sims2','sims3','sims4') default NULL,   `for` enum('yes','no') default NULL,   PRIMARY KEY  (`tid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; [/code] I hope this helps more
  7. Hi I know, a bit about php and mysql but I am having problems putting text boxes into a mysql table. Here is the code for the checkboxes (I don't know if that is right) [code]     <tr>         <td>&nbsp;Expansions:</td>         <td><input type="checkbox" id="expansions[]" value="sims2," /> Sims 2   <input type="checkbox" id="expansions[]" value="university," /> University <input type="checkbox" id="expansions[]" value="nightlife," /> Nightlife <input type="checkbox" id="expansions[]" value="ofb," /> Open For Business</td>       </tr>       <tr>         <td>Extra Packs </td>         <td><input type="checkbox" id="expansions[]" value="christmass," /> Christmas   <input type="checkbox" id="expansions[]" value="familyfunstuff," /> Family Fun Stuff <input type="checkbox" id="expansions[]" value="glamoursims," /> Glamour Life</td>       </tr> [/code] and here is the sql insert [code=php:0] $addsims2 = "insert into web_sims2 values ('','$_POST[name]','$_POST[date]','$_POST[description]','$_POST[download]','$_POST[custom_content]','(This is where the check box data needs to go) ','$_POST[type]')";     mysql_query($addsims2, $ServerConnect) or die(mysql_error()); [/code] The sql row type is [code] set('sims2', 'university', 'christmass', 'nightlife', 'ofb', 'familyfunstuff', 'glamoursims') [/code] Could any one help me please  :)
×
×
  • 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.