regdi Posted January 4, 2012 Share Posted January 4, 2012 Hi!I'm a new member here.. I was working in order to complete my computer assignment.. First, I made a.htm : <pre><form method=post action=d.php> Nama : <input type=text name=na size=25 maxlength=20> Alamat : <input type=text name=al size=40 maxlength=60> No.Telp : <input type=text name=no size=15 maxlength=15> Gender : <input type=radio name=ge value=L>Male <input type=radio name=ge value=P>Female Message : <textarea rows=5 cols=40 name=pe></textarea> <input type=submit name=submit value=Daftar> <input type=reset name=reset value=Batal> </form></pre> and : d.php <? $na=$_POST['na']; $al=$_POST['al']; $no=$_POST['no']; $ge=$_POST['ge']; $pe=$_POST['pe']; $tgl=date("Y-m-d"); echo $tgl; mysql_connect(connection details hidden for security purposes, but they definitely work); mysql_select_db("cb") or die("Database doesn't exist"); $sql="create table tamu(id int(3) auto_increment, nama varchar(20), alamat varchar(60), notelp varchar(15), gender set('L','P'), pesan text, tglcatat date, primary key (id))"; $hasil=mysql_query($sql); $sql="insert into tamu (nama, alamat, notelp, gender, pesan, tglcatat) values('$na','$al','$no','$ge','$pe','$tgl')"; $hasil=mysql_query($sql); $sql="select *from tamu"; $hasil=mysql_query($sql); echo"<pre>"; while($data=mysql_fetch_array($hasil)) { echo"ID : $data[id]<br>"; echo"Nama : $data[nama]<br>"; echo"Alamat : $data[alamat]<br>"; echo"No.Telp : $data[notelp]<br>"; echo"Gender : $data[gender]<br>"; echo"Pesan : $data[pesan]<br>"; echo"Tgl Catat : $data[tglcatat]<br><br>"; } ?> then, I open the a.htm, fill it, and push the submit button,but What I see is.. "; while($data=mysql_fetch_array($hasil)) { echo"ID : $data[id] "; echo"Nama : $data[nama] "; echo"Alamat : $data[alamat] "; echo"No.Telp : $data[notelp] "; echo"Gender : $data[gender] "; echo"Pesan : $data[pesan] "; echo"Tgl Catat : $data[tglcatat] "; } ?> What should I do?? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/254335-my-php-code-cant-be-run/ Share on other sites More sharing options...
Muddy_Funster Posted January 4, 2012 Share Posted January 4, 2012 You have an issue with your quotes somewhere from the look of it. copy and paste your exact code, using code or php tags to enclose it. Quote Link to comment https://forums.phpfreaks.com/topic/254335-my-php-code-cant-be-run/#findComment-1304113 Share on other sites More sharing options...
kicken Posted January 4, 2012 Share Posted January 4, 2012 If your seeing the PHP code instead of it being run, there are two likely causes for this: 1) Your using <? rather than <?php for your starting tag. <? is known as a short tag and is not valid unless enabled (it is not enabled by default I believe). You should always use <?php as it will always work. 2) Your server is not properly configured to parse PHP files. Fix number one first and then try. If you still have problems try re-installing your server. If you still have problems you'll have to post more details about your setup (os, server software, how you installed it, etc). Quote Link to comment https://forums.phpfreaks.com/topic/254335-my-php-code-cant-be-run/#findComment-1304132 Share on other sites More sharing options...
Maq Posted January 4, 2012 Share Posted January 4, 2012 Make sure you're using localhost and NOT the filesystem path. In the future, please place OR tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/254335-my-php-code-cant-be-run/#findComment-1304305 Share on other sites More sharing options...
regdi Posted January 6, 2012 Author Share Posted January 6, 2012 Thanks for the reply I can solve it now Thank you very much ^^, Quote Link to comment https://forums.phpfreaks.com/topic/254335-my-php-code-cant-be-run/#findComment-1304783 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.