Jump to content

tanvirzafar

Members
  • Posts

    14
  • Joined

  • Last visited

Posts posted by tanvirzafar

  1. i am making a simple php discussion forum.But when i intert data into database using form input the output data is not shown in output table.i verified that data is enter into database tables sucessfully.on output page the rows increas as data enter but data is not show on that rows...here is the output page code

    $host="localhost"; // Host name$username=""; // Mysql username$password=""; // Mysql password$db_name="itinsight"; // Database name$tbl_name="forum_question"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");$sql="SELECT * FROM $tbl_name ORDER BY id DESC";// OREDER BY id DESC is order result by descending$result=mysql_query($sql);?><table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"><tr><td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td><td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td><td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td><td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td><td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td></tr><?php // Start looping table rowwhile($rows=mysql_fetch_array($result)){?><tr><td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td><td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td><td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td><td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td><td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td></tr><?php// Exit looping and close connection}mysql_close();?><tr><td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td></tr>

     

    here is the code of add new discussion

    <?php$host="localhost"; // Host name$username=""; // Mysql username$password=""; // Mysql password$db_name="itinsight"; // Database name$tbl_name="forum_question"; // Table name// Connect to server and select database.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// get data that sent from form$topic=$_POST['topic'];$detail=$_POST['detail'];$name=$_POST['name'];$email=$_POST['email'];$datetime=date("d/m/y h:i:s"); //create date time$sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";$result=mysql_query($sql);if($result){echo "Successful<BR>";echo "<a href=forum.html>View your topic</a>";}else {echo "ERROR";}mysql_close();?>

     

     

  2. what are you expecting it to do though? You make a connection and select a database, that's it. You don't aren't sending any output.

     

    However, 8080 is likely not the port you want to connect to. By default SQL server runs on port 3306. Just try "localhost"

    i try localhost...but it doesnot connect...as the other keyword become dark blue color in notepad++ these mysql_connect and mysql)select_db not become like other....not work???

  3. hello friends i have a problem..i create a page in localhost db.php here is its code

    <?php$con= mysql_connect("localhost:8080","root","");$db = mysql_select_db('gcuf',$con);?>

    it is looking fine...but it doesnot work....when i see the page where i include this one it does not show me any error also not connect to database...dont know what's going on...my apache is running on port 8080

    tell me its solution please??

  4. what have you done so far? any code?

    It is usually done by passing the id in GET request or POST Request and capture the data and then use WHERE clause in SELECT query to retireve that sepcified id.

    i get input of registratio_id from a forum with post method....i create a record.php file...connenct database and want to show record on student on the basis of registration id....here is the record.phph file...correct this code..

    <?php$con = mysql_connect("abc.com","colg","Pta@1","colg");// Check connectionif (mysql_connect_errno()) { echo "Failed to connect to MySQL: " . mysql_connect_error(); }$result = mysql_query($con,"SELECT * FROM fsc_engg_ics WHERE reg_id='".mysql_real_escape_string($con, $_POST["registrationid"])."'"$result = mysql_query($con, $sql);while($row = mysql_fetch_array($result)) { echo $row['f_name'] . " " . $row['l_name']; echo "<br>"; }?>

  5. OK! Submitted data and 1 record added apparently, so I guess its fixed, no errors displayed which would have shown if server was setup to display errors, this is my last comment on this topic bye.

    yup...i got it...its all due to you my bro...thanks alot :)

  6. Again! How could I possibly know I can't test it! I can't tell if column names are correct, I can't tell if posted value are correct or exist to be inserted into database, only YOU can do this.

    i checked all things you mention above...all are correct..please submit data into form and then tell me what the ###### such error is??

    igoc.com.pk/student_results/register_fsc_med_123.html

  7. No you at look at my post, and you correct your code, as you know more about what is username, hostname, password and database name than I do, or you should, if not! I suggest you look at tutorials on how to connect to MySQL database.

    and what about the rest code..???is it correct??

  8. Database name if string should be within quotesmysql_select_db('colg');If variablemysql_select_db($colg);The database connection should contain host, username, and passwordmysql_connect('abc.com', 'colg', 'Colg@1');Is this correct? or have you used database name for user by mistake.

    mysql_connect("abc.com","colg","Colg@1","colg");

    please correct the code mention above..

  9. hello everybody...i have an error when i submit data into database..please check it out..phph code is<?php$con= mysql_connect('abc.com', 'colg', 'Colg@1');if (!$con) {die('Could not connect: ' . mysql_error());}mysql_select_db(colg);$sql="INSERT INTO fsc_med(reg_id,f_name,l_name,roll_num,t_eng,o_eng,t_urdu,o_urdu,t_phy,o_phy,t_che,o_che,t_bio,o_bio, t_isl_sstd,o_isl_sstd,total_marks,obtain_marks,attendance)VALUES('$_POST[reg_num]','$_POST[firstname]','$_POST[lastname]','$_POST[rollnum]','$_POST[t_english]','$_POST[o_english]','$_POST[t_urdu]','$_POST[o_urdu]','$_POST[t_physics]','$_POST[o_physics]','$_POST[t_chemistry]','$_POST[o_chemistry]','$_POST[t_biology]','$_POST[o_biology]','$_POST[t_isl_sst]','$_POST[o_isl_sst]','$_POST[t_marks]','$_POST[o_t_marks]','$_POST[attdnce]')";if (!mysqli_query($con,$sql)){die('Error: ' . mysqli_error($con));}echo "1 record added";mysqli_close($con);?>data entry form is here http://igoc.com.pk/student_results/r...c_med_123.html

  10. hello everyone...i have a database of student result...i want to show record of student on its roll number..but there are some fields that i want empty in some cases...i don't want those empty or null fields to show in result or output ....please tell me what is the query for this purpose...

×
×
  • Create New...