Jump to content

Nazirul

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    UiTM Malaysia

Nazirul's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. +a.. it will formulate the invalid xml form... i mean the <?xml.... will be twice or ++ ive change the code... but i still cant insert the XSL <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Adding Songs...</title> <style type="text/css"> em { text-align:center; } </style> </head> <body> <p> <? $songs = Array(); function start_element($parser, $name, $attrs){ global $songs; if($name == "song"){ array_push($songs, $attrs); } } function end_element ($parser, $name){} $playlist_string = file_get_contents("student.xml"); $parser = xml_parser_create(); xml_set_element_handler($parser, "start_element", "end_element"); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parse($parser, $playlist_string) or die("Error parsing XML document."); print "<br />"; if($_POST['action'] == "ins"){ array_push($songs, Array( "Student_Number" => $_POST['Student_Number'], "title" => $_POST['name'], "artist" => $_POST['artist'], "path" => $_POST['path'], "address" => $_POST['address'], "under" => $_POST['under'])); $songs_final = $songs; }else if($_POST['action'] == "del"){ $songs_final = Array(); foreach($songs as $student){ if($student['title'] != $_POST['name']){ array_push($songs_final, $student); } } } $write_string = "<?xml-stylesheet type="text/xsl" href="viewstudent.xsl"?>" $write_string = "<Students>"; foreach($songs_final as $student){ $write_string .= "<song Student_Number=\"$student[student_Number]\" title=\"$student[title]\" artist=\"$student[artist]\" path=\"$student[path]\" address=\"$student[address]\" under=\"$student[under]\" />"; } $write_string .= "</Students>"; $fp = fopen("student.xml", "w+"); fwrite($fp, $write_string) or die("Error writing to file"); fclose($fp); print "<em>Song inserted or deleted successfully </em><br />"; print "<a href=\"index.php\" title=\"return\">Return</a>"; ?> </p> </body> </html> it result an error with message : where line 45 is $write_string = "<?xml-stylesheet type="text/xsl" href="viewstudent.xsl"?>" is it incorrect syntax? lol.. im tired.. , helpp
  2. Hello All this is the code for outputting XML file using PHP.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Adding Songs...</title> <style type="text/css"> em { text-align:center; } </style> </head> <body> <p> <?php $students = array(); $playlist_string = file_get_contents( 'student.xml' ); $parser = xml_parser_create(); xml_set_element_handler( $parser, 'start_element', 'end_element' ); xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0); xml_parse( $parser, $playlist_string) or die( 'Error parsing XML document.' ); echo '<br />'; if( $_POST['action'] == 'ins' ) { array_push( $students, array( 'room_number' => $_POST['room_number'], 'Student_Number' => $_POST['Student_Number'], 'student_name' => $_POST['name'], 'course' => $_POST['course'], 'semester' => $_POST['semester'], 'address' => $_POST['address'], 'under' => $_POST['under']) ); $students_final = $students; } else if($_POST['action'] == "del") { $students_final = array(); foreach($students as $student) { if($student['Student_Number'] != $_POST['Student_Number']){ array_push($students_final, $student); } } } //Write XML vers and enctype $write_string .= '<?xml version="1.0" encoding="iso-8859-1"?>'; // Write root tag open tag <root> $write_string .= '<Perindu>'; $write_string .= '<Student>'; foreach( $students_final as $student ) { $write_string .= '<Room number="Perindu">'; $write_string .= '<Student_Number>'.$student[student_Number].'</Student_Number>'; $write_string .= '<Student_Name>'.$student[student_name].'</Student_Name>'; $write_string .= '<Course>'.$student[course].'</Course>'; $write_string .= '<Semester>'.$student[semester].'</Semester>'; $write_string .= '<Undergraduated_From>'.$student[under].'</Undergraduated_From>'; $write_string .= '<Address>'.$student[address].'</Address>'; $write_string .= '</Room>'; } // Write root tag close tag </root> $write_string .= '</Student>'; $write_string .= '</Perindu>'; $fp = fopen('student.xml', 'w+'); fwrite($fp, $write_string) or die('Error writing to file'); fclose($fp); echo '<em>News Article inserted or deleted successfully <em><br />'; echo '<a href="addstudent.php" title="return">Return</a>'; function start_element( $parser, $name, $attrs ){ global $students; if( $name == 'student' ){ array_push($students, $attrs); } } function end_element ($parser, $name){} ?> </p> </body> </html> the problem was... it keep overwriting my XML file and it can only store 1 data... i've working for it for an hour but no luck... Master plz tell me where the errors.. thank you
  3. lol .. do u mean when a user log in, then the script will UPDATE the SQL in the column 'active' u can do such : once the correct id and password; if (mysql_num_rows($result) == 1) { //sql UPDATE here
  4. not work.. i think the reason why it works might be.. the php ignore the '<room_number' n etc... and only display the $value my friend email me the working code and it is : <?php ob_start(); session_start(); ?> <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="detail.xsl"?> <!DOCTYPE recipe SYSTEM "detail.dtd"> <recipe> <?php $id = $_GET['id']; include("library/config.php"); include("library/opendb.php"); $sql = "SELECT * FROM recipe WHERE id = '$id' AND act = '0'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $cat_id = $row['category']; $sql = "SELECT cat_name FROM category WHERE id = '$cat_id'"; $result2 = mysql_query($sql); $r = mysql_fetch_array($result2); ?> <data> <recId><?php echo $id; ?></recId> <recTitle><?php echo $row['title']; ?></recTitle> <ingredient><?php echo $row['ingredient']; ?></ingredient> <instruction><?php echo $row['instruction']; ?></instruction> <suggestion><?php echo $row['suggestion']; ?></suggestion> <comment><?php echo $row['comment']; ?></comment> <source><?php echo $row['source']; ?></source> <sender><?php echo $row['name']; ?></sender> <email><?php echo $row['email']; ?></email> <date><?php echo $row['date']; ?></date> <catId><?php echo $cat_id; ?></catId> <catName><?php echo $r['cat_name']; ?></catName> </data> <formFunction> <approve><a href='approve.php' class='content'>Approve</a></approve> </formFunction> <?php include("library/closedb.php"); ?></recipe> great thanks : DarkSuperHero you are very helpful...
  5. lol.. use ----> php 5 <?php echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; echo '<?xml-stylesheet type="text/xsl" href="ViewStudent2.xsl"?>'; echo '<student>'; echo '<room_number>'. $room_number .'</room_number>'; echo '<student_number>'. $student_number .'</student_number>'; echo '<student_name>'. $student_name .'</student_name>'; echo '<student_course>'. $student_course .'</student_course>'; echo '<semester>'. $semester .'</semester>'; echo '<address>'. $address .'</address>'; echo '<under>'. $Undergraduate_From .'</under>'; echo '</student>'; ?> that works... but the XSL cant be used .. echo '<?xml-stylesheet type="text/xsl" href="ViewStudent2.xsl"?>';
  6. well... the error was in line 28 .. that refer to the <?xml version="1.0" encoding="windows-1252"?> im not sure if it either php version problem...im using php 4.4.8 right now.. i've tried this <studNumber><? $Student_Number ?></studNumber> but no luck...
  7. Hi... i want to declare XML in PHP just like ASP code below : <!--#include file="ADOVBS.INC"--> <% Set ConnObj = Server.CreateObject("ADODB.Connection") Set RstObj = Server.CreateObject("ADODB.Recordset") ConnObj.Open "spa" sql="select *from CUSTOMER" set RstObj=ConnObj.Execute(sql,RecordsAffected) %> <?xml version="1.0" encoding="windows-1252"?> <?xml-stylesheet type="text/xsl" href="ViewAllSpaCust.xsl"?> <Senarai_Pelanggan> <% While not rstobj.eof %> <senarai> </senarai><senarai><Nama><%=rstobj("CUSTNAME")%></Nama> <NoIc><%=rstobj("CUSTIC")%></NoIc> <Gender><%=rstobj("CUSTGENDER")%></Gender> <Address><%=rstobj("CUSTADDRESS")%> </Address> <Race><%=rstobj("CUSTRACE")%></Race> <Dob><%=rstobj("CUSTDOB")%></Dob> <MobileNo><%=rstobj("CUSTMOBILENO")%></MobileNo> <HomeNo><%=rstobj("CUSTHOMENO")%></HomeNo> <MemberDate><%=rstobj("CUSTMEMBERDATE")%></MemberDate> </senarai> <%rstobj.MoveNext%> <%wend%> </Senarai_Pelanggan> what is the similar syntax for the XML embedded in PHP just like the ASP.. i've tried : <?php //php code goes here ?> <?xml version="1.0" encoding="ISO-8859-1"?> .. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>... but no luck.. it give error : hmm..
  8. lol.. i really learn something today... thanks buddy.. whatever n whenever.. i have to put session_start(); when i want to use session on the page that use and will use the session the error is due to i forgot to put the ';' ... very funny lol ... but before this, when i use the session on the same page without the 'session_start();' ... it still display what i type in the textbox on the same page... so weird.. thanks again everyone..
  9. when i insert session_start() , i come up with this error what is that
  10. hello i've tried it to passing a value from a textbox into another page... it works on the same page bt when i try to use the session, its not work this is from page A $_SESSION['studentNom'] = $_POST['Student_Number']; and this is from page B to use that session.. echo $_SESSION['studentNom']; // echoing the session but it has no value... $id = $_SESSION['studentNom']; so my question is, what is the appropriate manner to retrieve the session... and this is some of the php coding in page B <?php $db_name = "student"; $table_name = "student_information"; $connection = @mysql_connect("localhost", "root", "pass") or die(mysql_error()); $db = @mysql_select_db($db_name, $connection) or die(mysql_error()); echo $_SESSION['studentNom']; id = $_SESSION['studentNom']; $sql = "SELECT * FROM $table_name WHERE NO_PELAJAR = '$id'"; .... thanks
  11. lol... its damn true... php wut? calendar is usually using a javascript anyway.. contact the script owner for more information...
  12. Hello all i want to upload an XML file into MySQL this is the form example <form method="post" enctype="multipart/form-data"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td width="246"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="xmlfile" type="file" id="xmlfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> it looks like : in MySQL 6.0, we can load xml file into mysql using this code : LOAD XML LOCAL INFILE 'student.xml' INTO TABLE student_information ROWS IDENTIFIED BY '<student_information>'; so my question is, how do we upload the file and at the same time run the LOAD XML code... help me to figure it out. thanks..
  13. lol... this is the answer... how can i miss it... duhh thanks CloudSex13 and everyone...
  14. yes and it is if(!isset($_SESSION)||($_SESSION['User_ID'])) { session_start(); }
×
×
  • 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.