473,382 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

problem with php code and the wamp.Dont know what is wrong with the my wamp

Hi, am new to php and have installed wamp but the problem is that my php code is not executed in the my web browser.Like the following is not executed;


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $student_name=$_POST[student_name];
  3. $year_of_study=$_POST[year_of_study];
  4. $email=$_POST[email];
  5. $reg_no=$_POST[reg_no];
  6. $password+=$_POST[password];
  7. try{
  8. $host="localhost";
  9. $username="root";
  10. $password="";
  11. $database="registration";
  12. $dsn="mysqlhost=$host,$dbname=$database";
  13. $conn=new PDO($dsn,$username,$password);
  14. $conn->setAttribute(PDO:ATTR_ERRMODE,PDO:ERRMODE_EXCEPTION);
  15. $SQL="INSERT INTO student registration("student_name,reg_no,year_of_study,password"")
  16. VALUES($student_name,$reg_no,$year_of_study,$password);
  17. $sql="select*FROM userdata";
  18. $userdata=$conn_query($sql);
  19. echo'<table>;
  20. echo'<tr>;
  21. echo'<th>student_name</th> <th>reg_no<?th
  22.      <th>email</th> <th>year_of_study</th> <th>password</th>;
  23.      echo'<tr>;
  24.      foreach($userdata as $userdata)
  25.      {
  26.      echo'<tr>;
  27.      echo'<td>$userprofile[student_name]</td>;
  28.      echo'<td>$userprofilep[email]</td>;
  29.      echo'<td>userprofile[reg-no]</td>;
  30.      echo'<td>userprofile[year_of_study]</td>
  31.      echo'<td>userprofile[password]</td>
  32.      echo'</tr>
  33.      }
  34.  
  35. echo'</table>;
  36. $conn=null;}
  37. catch(PDOException $e){$conn=null;
  38. exit("connection failed $e->getmessage0");
  39. }
  40. <?php reguire_once_connection.php?> <?php
  41. $process_form.html?>
Feb 9 '15 #1
1 1157
Claus Mygind
571 512MB
1. you have no HTML header information like this stuff
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3.  <head>
  4.  

2. you are referencing "userProfile" when your query calls "userData"

check out php manual on "foreach"
http://php.net/manual/en/control-structures.foreach.php

3. while I don't play with PDO much, I think you are forgetting the "FETCH" after the query and before the "FOREACH". So your not really working on a rowset. You may want to check out some examples here http://wiki.hashphp.org/PDO_Tutorial...SQL_Developers if you don't want to use the php manual. In my world you would use a "WHILE" statement to fetch each row that was returned from the query. This most likely would replace your "FOREACH" loop. Something like this
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $stmt = $db->query('SELECT * FROM table');
  3.  
  4. while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  5.     echo $row['field1'].' '.$row['field2']; //etc...
  6. }
Feb 16 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Farooq Khan | last post by:
hi, my development team has been assigned a project that involves writing our own Web service. i happen to be a C++ programmer, new to C#/ASP.net. i dont know where to begin with......any...
2
by: Pavel Novotny | last post by:
H I'm trying to import a | seperated text from string variable which represents a tabl with several fields, eg 6124079|PRIRUBA 11 DN250 PN6;CSN131160.0;11369.1;CSN131005.50|KS|11,100000|3437,...
6
by: Benjamin Bittner | last post by:
Hallo NG, ive found this script http://www.iisfaq.com/default.aspx?View=A399&P=109. Now i want to use that script in a web application. can someone plz help me to convert it, or show me a way to...
0
by: arunavlp | last post by:
hi, I am new to .net , i am using VB.Net (Web form). I dont know how to pass parameters to stored function. Regards, Arun.S
2
by: hojjatnikan | last post by:
please help me this code 62EH&5gx0wiqoQFw is this name ( Belux) but i dont know how convert it i dont know the algorithm of this code plead help me
2
by: Tiruak | last post by:
Hi there. Thanks in advance for the people reading and trying to help. I'm very begginer using flash and action script, and I tryed to do this one navigation menu. Since I dont have experience...
8
risk32
by: risk32 | last post by:
Hi all. I have a really confusing problem. I'm using Swing and I'm trying to do a confirmation box : int reply; String message = "Do you want to input another number?"; String title = "Input...
2
by: sailormoon | last post by:
this information i put in data.txt 11221 MOHD IRFAN 80 70 11222 NURUL FITRAH 80 90 11223 MOHD FARHAN 70 80 11224 WAFFIN WARDAH 80 60 11225 SYAMSUL 50 50 99999 TAMAT 0 0 #include<fstream.h>
2
by: sometingsometing | last post by:
hi, I am new and dont know what went wrong. from Tkinter import * import tkMessageBox from pysqlite2 import dbapi2 as sqlite class door: global simpleprint
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.