Jump to content

Adding data...


2old2learn?

Recommended Posts

what is MISSING from the end of this? (1) a period, (2) a comma, or (3)semicolon$sqldata = mysqli_query($dbcon, $sqlget) or die (' error getting data ') what is MISSING from the end of this? (1) !; (2) '; or (3) ";echo "<tr><th>ID</th<th>SRNumber</th><th>Tenant</th><th>Floor</th><th>Tower</th><th>Job Description</th><th>Labour Cost</th><th>Material Cost</th><th>Date TWA Sent to Tenant</th><th>Date TWA Approved</th><th>Date Parts Ordered</th><th>Supplier</th><th>Date Job Completed</th><th>Date Billing Given to Accounting</th></tr>

Link to comment
Share on other sites

  • Replies 251
  • Created
  • Last Reply
what is MISSING from the end of this? (1) a period, (2) a comma, or (3)semicolon$sqldata = mysqli_query($dbcon, $sqlget) or die (' error getting data ') what is MISSING from the end of this? (1) !; (2) '; or (3) ";echo "<tr><th>ID</th<th>SRNumber</th><th>Tenant</th><th>Floor</th><th>Tower</th><th>Job Description</th><th>Labour Cost</th><th>Material Cost</th><th>Date TWA Sent to Tenant</th><th>Date TWA Approved</th><th>Date Parts Ordered</th><th>Supplier</th><th>Date Job Completed</th><th>Date Billing Given to Accounting</th></tr>
Thanks....this is missing........>>>>> " ; <<<<<<....
Link to comment
Share on other sites

Now I get this error " Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\icc\display.php on line 36 "also forgot to add at the end </body></head>....oooops...

<html><style type="text/css">table {  border: 2px solid red;  background-color: #FFC;  } th {	border-bottom: 5px solid #000;	}td {   border-bottom: 2px solid #666;   }</style><head><title>Display Data</title></head><body><h1>Display Data</h1><?php//include("connect.php");$con = mysql_connect("localhost","root",""); if (!$con)   {   die('Could not connect: ' . mysql_error());   } mysql_select_db("tecicc", $con);$result = mysql_query("SELECT * FROM twal ORDER BY ID");$sqlget ="SELECT * From twal";$sqldata = mysqli_query($dbcon, $sqlget) or die (' error getting data ');echo <table>echo "<tr><th>ID</th<th>SRNumber</th><th>Tenant</th><th>Floor</th><th>Tower</th><th>Job Description</th><th>Labour Cost</th><th>Material Cost</th><th>Date TWA Sent to Tenant</th><th>Date TWA Approved</th><th>Date Parts Ordered</th><th>Supplier</th><th>Date Job Completed</th><th>Date Billing Given to Accounting</th></tr>";while($row =mysqli_fetch_array($sqldata, MYSQLI_ASSOC)){	 	 echo "<tr><td>";	 echo $row['id'];	 echo"</td><td>";	 echo $row['srnumber'];	 echo"</td><td>";	 echo $row['tenant'];	 echo"</td><td>";	 echo $row['floor'];	 echo"</td><td>";	 echo $row['tower'];	 echo"</td><td>";		 echo $row['job_description'];	 echo"</td><td>";	 echo $row['employee'];	 echo"</td><td>";	 echo $row['labour_cost'];	 echo"</td><td>";	 	 echo $row['material_cost'];	 echo"</td><td>";	 	 	 echo $row['tenant_contact'];	 echo"</td><td>";	 	 echo $row['phone_number'];	 echo"</td><td>";	 	 echo $row['date_twa_sent_to_tenant'];	 echo"</td><td>";	 	 echo $row['date_twa_approved'];	 echo"</td><td>";	 	 echo $row['date_parts_ordered'];	 echo"</td><td>";	 	 echo $row['supplier'];	 echo"</td><td>";		 echo $row['date_job_completed'];	 echo"</td><td>";	 	 echo $row['date_billing_given_to_accounting'];	 echo"</td><td>";	 	 	 echo $row['employee_comments'];	 echo"</td><td>";	 	 echo $row['manager_comments'];	 echo"</td></tr>";		 }</table>;	 ?></body></head>

Link to comment
Share on other sites

echo <table>
you are missing quotes around table tag.
</table>;
another quotes and echo missing
Link to comment
Share on other sites

you are missing quotes around table tag.another quotes and echo missing
I get a whole new error for this now..so I sent a copy of this to the person who did the css Video tutorial..to see what I did wrong.????Thanks...your still the best..
Link to comment
Share on other sites

Hey well I think I am making some progress..I now got the css to work..and now I get this error...

Error: Please check Your data entry You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Thank You.)' at line 3
Here are the two files..used ...CSS_form
<html><head><link href="style.css" rel="stylesheet" type="text/css"></head><body><div id="container"><div id="header"></div><div id="leftnav"><!--OPEN MENU-->    <div id="menu">		 <h2>Menu</h2>	 <li><a href="http://www.teamcombatleague.com/tecicc/index.php" title="Home">Home</a>	 <li><a href="http://www.teamcombatleague.com/tecicc/index_sr.php" title="Service Requests">TWAL</a>	 <li><a href="http://www.teamcombatleague.com/tecicc/display.php" title="Records">Records</a></li>	 		  </div><!--CLOSE MENU--></div><div id="body"><div class="twal"><form action="insert.php" method="post"><center><table border="0"><center><caption>Tenant Work Authorization Log</caption></center></table></center><br><center><table class="space" border="1"> <tr align="right"><tr><td>SR Number:</td><td><input type="text" name="srnumber" /></td> <td>Tenant:</td><td><input type="text" name="tenant" /></td> <td>Tower:</td><td><input type="text" name="tower" /></td> <td>Floor:</td><td><input type="text" name="floor" /></td> <tr></tr> <tr><td>Job Description:</td><td><input type="text" name="job_description"></td> <td>Employee:</td><td><input type="text" name="employee"></td> <td>Labour Cost:</td><td><input type="text" name="labour_cost" /></td> <td>Material Cost:</td><td><input type="text" name="material_cost" /></td> </table></center> <center> <table class"space" border="1">  <tr><td>Supplier:</td><td><input type="text" name="supplier" /></td> <td>Date TWA Sent to Tenant:</td><td><input type="text" name="date_twa_sent_to_tenant" /></td> <td>Date TWA Approved:</td><td><input type="text" name="date_twa_approved" /></td>  <tr align="right"><td align="right">Date Parts Ordered:</td><td><input type="text" name="date_parts_ordered" /></td> <td>Date Job Completed:</td><td><input type="text" name="date_job_completed" /></td> <td>Date Billing Given to Accounting:</td><td>  <input type="text" name="date_billing_given_to_accounting" /></td></tr> </table> <center><table border="1"><center><caption>Office Use:</caption></center></table></center><br> <table border="1"> <td>Employee Comments:</td><td>  <textarea rows="5" cols="40" name="employee_comments"></textarea></td> <td>Managers Comments:</td><td>  <textarea rows="5" cols="40" name="managers_comments"></textarea></td> </table> </table></center><center> <input type="submit" /><br><br> </center> </form></div></div><div id="footer">2007-2011 Copyright Bill Juschko</div></body></html>

Now insert code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>insert_data.php</title></head><body><?php $con = mysql_connect("localhost","xxxxxxx","xxxxxxx"); if (!$con)   {   die('Could not connect: ' . mysql_error());   } mysql_select_db("xxxxxxxx", $con); $sql="INSERT INTO twal ( srnumber, tenant, floor, tower, job_description, labour_cost, material_cost, date_twa_sent_to_tenant, date_twa_approved, date_parts_ordered, supplier, date_job_completed, date_billing_given_to_accounting, employee_comments, managers_comments ) VALUES ('$_POST[srnumber]','$_POST[tenant]','$_POST[floor]','$_POST[tower]','$_POST[job_description]','$_POST[labour_cost]','$_POST[material_cost]','$_POST[date_twa_sent_to_tenant]','$_POST[date_twa_approved]','$_POST[date_parts_ordered]','$_POST[supplier]','$_POST[date_job_completed]','$_POST[date_billing_given_to_accounting]','$_POST[employee_comments]','$_POST[managers_comments])";if (!mysql_query($sql,$con));   {   die('Error: Please check Your data entry ' . mysql_error());   } echo "1 record added"; mysql_close($con); ?> </body></html>

In the database the settings are as follows:srnumber - varchartenant - varcharfloor - varchartower - varcharjob_description - varcharlabour_cost - varcharmaterial_cost - varcharsupplier - varchardate_twa_sent_to_tenant - varchardate_twa_approved - varchardate_parts_ordered - varchardate_job_completed - varchardate_billing_given_to_accounting - varcharemployee_comments - varcharmanagers_comments - varcharis these database setting correct..I'm not too sure..maybe comments should be mediumblob..???

Link to comment
Share on other sites

for every starting single quote, there must be a end single quote,'$_POST[managers_comments])";should be ,'$_POST[managers_comments]')";
OOOOOps..missed that one..LOL thanks..will check it out now..TESTED AND GET THIS ERROR NOW:Error: Please check Your data entryOkay I think I found it .. see help here is great, even though it was the ]'); forgotten I also forgot to add " employee " to insert...LOL
Link to comment
Share on other sites

I still get this errorError: Please check Your data entryokay here is my database headings?

id srnumber tenant floor tower job_description employee labour_cost material_cost date_twa_sent_to_tenant date_twa_approved date_parts_ordered supplier date_job_completed date_billing_given_to_accounting employee_comments managers_comments
Note I don't have the Id in the form...could this be the problem.????also on a side note..how do I get the form to fill the width of the body???thanks
Link to comment
Share on other sites

You don't add semicolon to a if conditionif (!mysql_query($sql,$con)); { die('Error: Please check Your data entry ' . mysql_error()); }should beif (!mysql_query($sql,$con)) { die('Error: Please check Your data entry ' . mysql_error()); }

Link to comment
Share on other sites

You don't add semicolon to a if conditionif (!mysql_query($sql,$con)); { die('Error: Please check Your data entry ' . mysql_error()); }should beif (!mysql_query($sql,$con)) { die('Error: Please check Your data entry ' . mysql_error()); }
Hmm...don't know how that snuck in there..trying it out now....thanks...Nope still get error...Please check your data entry...
Link to comment
Share on other sites

Hmmm even though it gives an error message..the data is inserted into the database..very strange...hey should employee_comments and managers_comments be mediumtext or mediumblog...??? right now they are varchar(255)

Link to comment
Share on other sites

also on a side note..how do I get the form to fill the width of the body???
being a block element the form element should stretch to total width of its parent element, if it parent being a table or div container width has been set a width smaller than browser width, it will stretch to that width only.
Link to comment
Share on other sites

Hmmm even though it gives an error message..the data is inserted into the database..very strange...hey should employee_comments and managers_comments be mediumtext or mediumblog...??? right now they are varchar(255)
using varchar(255) should be fine, does the comment text have any apostrophes, within it?
Link to comment
Share on other sites

being a block element the form element should stretch to total width of its parent element, if it parent being a table or div container width has been set a width smaller than browser width, it will stretch to that width only.
Okay thanks got that <table cellpadding="5" did it..
Link to comment
Share on other sites

using varchar(255) should be fine, does the comment text have any apostrophes, within it?
no but in labour cost and material cost...I put like 40.00 and 20.00Edited..okay changed labour cost and material cost to numeric..." Double "
Link to comment
Share on other sites

IF the ID is int and set to auto_increment, no you do not need this in the form at all.
Okay ID is int and set to auto_increment..thanks for clearing that uphow about the Labour cost and Material cost..what setting should they be..???
Link to comment
Share on other sites

they should use decimal, but you could use float or double, but i would stick with decimal for now.
Okay changing that now..Okay also I input dates this way into the input box... 5/1/11 its done this way for all date fieldsIs that okay...
Link to comment
Share on other sites

i would use the typical (this is uk date format) dd/mm/yyyy so todays date would be 01/05/2011, sorry i don't know what date format they use in never never land.
LOL okay thanks...lolin the database settings does it give me options to set it that format???gone to check it now...okay notice given option of current_timestamp..in default or as defined...is that right..okay did " date " and the extra field in default I set this in it... 00/00/0000
Link to comment
Share on other sites

OK! apparently you have to use format of YYYY/MM/DD, and there are several datatype options to use check out http://www.tizag.com/mysqlTutorial/mysql-date.php which will give you run down on different date types, and how to use them.basically they will be stored in this set format, then it is up to you to define the format you require to display it, with timestamp you would use echo date("m/d/Y", $timestamp_from_DB);

Link to comment
Share on other sites

OK! apparently you have to use format of YYYY/MM/DD, and there are several datatype options to use check out http://www.tizag.com/mysqlTutorial/mysql-date.php which will give you run down on different date types, and how to use them.basically they will be stored in this set format, then it is up to you to define the format you require to display it, with timestamp you would use echo date("m/d/Y", $timestamp_from_DB);
So I would do this??
query_manual = "INSERT INTO twal (date_twa_sent_to_tenant, date_twa_approved, dp_date)<<<< something like this...not sure what the dp_date is for though..	VALUES ('DATE: Manual Date', '2020-2-14')";$query_auto = "INSERT INTO dateplayground (dp_name, dp_date)	VALUE ('DATE: Auto CURDATE()', CURDATE() )";mysql_query($query_manual) or die(mysql_error());mysql_query($query_auto) or die(mysql_error());

do I create a table called " date " ?

Link to comment
Share on other sites

basically they will be stored in this set format, then it is up to you to define the format you require to display it, with timestamp you would use echo date("m/d/Y", $timestamp_from_DB);
This is what I recommend also, I prefer to store date information as a Unix timestamp (which also stores time information), and then if the display requirements ever change you should be able to use the data you have to display it how you want. Today you might only display a date, but later you could also display the time if you want to. So I prefer to use an int column for my dates, and I use PHP's various date functions to get the timestamp I want to store in that field. The timestamp is just an integer, the number of seconds since 1/1/70.The time function gets the current timestamp:http://www.php.net/manual/en/function.time.phpThe mktime function gets the timestamp for a specific date/time:http://www.php.net/manual/en/function.mktime.phpAnd the date function lets you format that date/time information however you want to display it:http://www.php.net/manual/en/function.date.phpNote that if you're storing the entire date/time, you can also let the user choose a preference about how those get displayed. They might want UK format, for example, or they might be looking for something a bit more modern. The key is to just store the integer timestamps in the database, and use the date function to format it for display. When working with integers it's also easy to add or subtract days or time, get database records between specific dates, etc, everything is just regular integer math.
$now = time();$sql = 'INSERT INTO invoices(..., invoice_date) VALUES (..., ' . $now . ')';

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...