That's how I learnt....after learning the basics, you can vary the way you make your dish based on the ingredients you use to flavor it...and Presto! you've made your most delicious dish...lol...
maydhyam 38 Posting Pro :)
That's how I learnt....after learning the basics, you can vary the way you make your dish based on the ingredients you use to flavor it...and Presto! you've made your most delicious dish...lol...
I hear and I forget. I see and I remember. I do and I understand. ~ Confucius
Hello....do you all understand what I have done/am trying to do?
Here are my 2 php files...
billUpload.php
.
.
.
<?php
include('./uploadBill.php');
?>
<tr>
<td colspan="6">
<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data">
<table>
<tr>
<td>
<p align="left"><span class="style4 style25 style28">Bill Uploader </span></p>
<p align="left"><span class="style21 style29">The Bill Uploader works in 2 steps.</span></p> </td>
</tr>
<tr><td><p> </p></td></tr>
<tr>
<td>
<table width="950" border="0" align="center" cellpadding="1" cellspacing="0" >
<tr>
<td><p> </p></td>
<td colspan="4" bgcolor="#006600">
<p align="left" class="style32">
<span class="style21 style33">Step 1: Browse for file</span></p> </td>
<td><p> </p></td>
</tr>
<tr>
<td><p> </p></td>
<td bgcolor="#006600"><p> </p></td>
<td width="125" bgcolor="#006600" scope="row"><div align="left" class="style13 style29 style31">Browse</div></td>
<td width="356" bgcolor="#006600">
<div align="left">
<strong>
<input id="file" type="file" name="file" size="30" />
</strong>
</div>
</td>
<td bgcolor="#006600"><p> </p></td>
<td><p> </p></td>
</tr>
<tr width="950">
<td><p> </p></td>
<td colspan="4" bgcolor="#006600">
<p align="left"><strong>
<span class="style21 style30">Step 2: Upload the file selected</span></strong></p> </td>
<td><p> </p></td>
</tr>
<tr>
<td><p> </p></td>
<td bgcolor="#006600"><p> </p></td>
<td bgcolor="#006600"><p> </p></td>
<td bgcolor="#006600">
<div align="left">
<strong>
<input name="btnSubmit" type="submit" id="btnSubmit" value="Upload">
</strong>
</div>
</td>
<td bgcolor="#006600"><p> </p></td>
<td><p> </p></td>
</tr>
</table>
<?
upload();
?>
</td>
</tr>
</table>
</form>
</td>
</tr>
.
.
.
I am not sure if this is correct...but the code below is where I would like the file that was selected in the code above to be read, and have the data inserted into the MySQL database.
When I try to upload a file, nothing happens...as well as, where <? upload(); ?> is located, the code after it doesn't display... (It's like it's blocked)
uploadBill.php
<?php
include "./connect.php";
function upload()
{
global $conn;
if(isset($_POST['btnSubmit']))
{
$filename=$_FILES['file']['tmp_name'];
$import = "load data local infile ".$filename." INTO table testtsttbills FIELDS TERMINATED BY …
I did that, and it doesn't show any errors now...thank you...but my code still doesn't work...may I display the code?
I love to drink tea as well.....I like to try out new flavours too....I drink coffee only when I am out of tea...in the soda category, I like cokes, but not too often...lol...
Just had pasta, string beans and chicken....:) it tasted yummy...:)
How could I put the following sql statement into a php variable?
load data local infile ".$filename." INTO table testtsttbills FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'(account,service,date,time,timebandtype,destination,callednumber,mins,airtimecharge,tollcharge,amt,privatenumber)
when I tried to putting it in the variable...it's showing not working because it recognizes the double quote in ENCLOSED BY '"' as an open double quote and not as what it is enclosed by...
any help?
Peanut Punch
1/3 cup smooth peanut butter
14 oz. can evaporated milk
14 oz. can condensed milk
1 cup water
1 tbsp. sugar
1 egg
pared peel of lime or lemon
1 tsp. vanilla extract
2 cups white rum (for example: vodka) or 1 cup milk
Mix the peanut butter with the evaporated milk. Add condensed
milk and water, mix well. Taste, if not sweet enough add sugar. beat egg with
peel, disacard peel. Add egg mixture, vanilla, and milk (or rum) to peanut
mixture. Bottle and chill. Serve with ice.
You may have a fresh start any moment you choose, for this thing that we call 'failure' is not the falling down, but the staying down. ~ Mary Pickford
Ok, well I am closing this thread...I will start with a new thread...
So that piece of code works, I am able to upload the data into a table in the database....but that was done through MySQL Query Browser...I gotta get that piece of code to work with my upload button now...
Hi,
Ok, I'll give it a try and keep you all posted...:)
Oh, and nope, I do not want that everything be done for me...I was merely stating what I want to get done, and if there's anyone who can guide me along....:)...if it came across that way, then I must say that that was not my intention...
so, like I said, I'll give niek_e's example a shot, and I'll let you all know...:)
Thanks much in advance...:)
May
Yea, but the files to be uploaded are monthly...and are therefore named differently...so I can't have a static name in the code...
Try this for the SQL statement
"SELECT * FROM STOCKS WHERE STOCK_CODE = '.$stock_code.'";
Hi All,
Well I did look at the links you gave and the phpmyadmin isn't what I was looking for, and as for the website link, I actually looked at that site before, and it helps me understand a lil bit about the uploading but it does not allow the user to actually select a file (with a browse button...sorta like thos picture uploader, but this time it's a CSV uploader)...I hope I am not confusing you...
Hi,
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =sendmail -t -i
Hi All,
To Daedal...no, I haven't tried phpmyadmin...I would look into that now...
To Pritaeas...I would also now look at the website you have given to me...
To All...I will keep you all posted on my progress...
Thank much in advance...
May
Good Morning,
I have a CSV file with thousands of rows of data, and I want to have this data uploaded into a table in a MySQL database. I also want an area where the file could be selected from the computer for the data to be uploaded.
Could this be done?
If it could, kindly guide me through getting it done...
May
Hey Vai,
So I put the piece of code into all my pages, and they worked nicely...I now understand how to set the sessions for my application....Thanks...
May
Hey,
I typed the incorrect page name in the header....I corrected it, and now it works...I just want to make sure and enter it into my other pages, and verify that they all work...
I'll keep you posted...
May
So I created secure.php and also in my apHome.php script, i added the code snippet you told me to...and when i typed the direct link into the address bar to open apHome.php....I am getting the "Internet Explorer cannot display the webpage" message..so this is how it is done? the hiding/protection of the page "apHome.php"?
here is what i have on my login page...:
$_SESSION['username'] = $_POST['user'];
$_SESSION['password'] = $md5pass;
logininfo();
header("Location: apHome.php");
here is what i have on my home page...:
<?php
session_start();
include('./connect.php');
if (isset($_SESSION['username']))
{
$name = $_SESSION['username'];
}
?>
i have other pages linked from this homepage, and i want to include them in this session ( so that even if i type the direct link in the address bar, i would ot be able to access the page)...
Hi,
Is the following piece of code what you are talking about?
<?php
session_start();
include('./connect.php');
if (isset($_SESSION['username']))
{
$name = $_SESSION['username'];
header("Location: DatabaseRecorder.php");
}
?>
How do I set the session on a page, so that if I were to type the direct link for the page into the address bar, it doesn't display, instead the user would be redirected to the homepage or login page?
got it....thanks...
Great, it works now...I've even set it to send mails in HTML and not plain text.....
//send email
$to = "somebody@somewhere.com";
$subject = "blah blah";
$from = "TAIS Application";
$msg = "<html><head><title>blah blah</title></head>";
$msg .= "<body><table><tr><th align='left'><font face='verdana' size='2'>Dear System Administrator,</font></th></tr>";
$msg .= "<tr><th align='left'> </th></tr>";
$msg .= "<tr><th align='left'><font face='verdana' size='2'>User <font color='red'>".$myrow['FirstName']." ".$myrow['LastName']."</font> (<font color='red'>".$empNo."</font>) has blah blah.</font></th></tr>";
$msg .= "<tr><th align='left'><font face='verdana' size='2'>Kindly fix that problem.</font></th></tr>";
$msg .= "<tr><th align='left'> </th></tr>";
$msg .= "<tr><th align='left'><font face='verdana' size='2'>Regards</font></th></tr>";
$msg .= "<tr><th align='left'><font face='verdana' size='2'>TAIS Administration</font></th></tr></table></body></html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: ".$from."\r\nReply-To:someone@somewhere.com" . "\r\n";
$mailsend = mail("$to","$subject","$msg","$headers");
echo $mailsend ? "<img src='images/emailGone.gif' /> Notification was sent." : "<img src='images/emailNotGone.png' /> Notification sending failed.";
I reposted this query, and it was solved there...
Naveen, It works...wow...thank you so very much...
This is my code with the print_r($_POST); as well as the print out of the query...
print_r($_POST);
if($_POST['upDate'])
{
$accessType=$_POST['accessType'];
$empnumber = $_POST['empnumber'];
$q2 = "UPDATE Operators SET accessLevel=".$accessType." WHERE EmployeeID =".$empnumber;
echo $q2;
$result2 = mysql_query($q2, $conn) or die("Update not successful");
}
When I entered the EmployeeID and clicked search, this is the message I'm seeing...
Array ( [empNo] => 114301 [btnSubmit] => Submit )
Then when I entered my selection on the select box, this is the message....
Array ( [empNo] => [accessType] => User [empnumber] => 114301 [upDate] => Update ) UPDATE Operators SET accessLevel=User WHERE EmployeeID =114301Update not successful
Hi,
I made the changes (I even tried the mysql_real_escape_string) but when I tried to load the page to begin the search, nothing shows...
if($_POST['upDate'])
{
$accessType=$_POST['accessType'];
$empnumber = $_POST['empnumber'];
$q2 = sprintf("UPDATE Operators SET accessLevel=".$accessType." WHERE EmployeeID =".$empnumber), mysql_real_escape_string($accessType, $conn), mysql_real_escape_string($empnumber, $conn);
$result2 = mysql_query($q2, $conn) or die("Update not successful");
}
when I took out the mysql_real_escape_string code, then everything shows perfectly, but the update doesn't work...
if($_POST['upDate'])
{
$accessType=$_POST['accessType'];
$empnumber = $_POST['empnumber'];
$q2 = "UPDATE Operators SET accessLevel=".$accessType." WHERE EmployeeID =".$empnumber);
$result2 = mysql_query($q2, $conn) or die("Update not successful");
}
ok, well...I have the searchUser.php script which displays the input box and submit button...just under the submit button, there is a call for the validateData function in the validateUser.php script, when the submit button is pressed, the validateData function checks the input box (validation code) and in the midst of the validateData function, the confirmData function is called; that is where I put the results to show provided the data was confirmed...it is within these results that I want the form for the update, i.e. alongside the results, there is a select box with the update button, so that when I choose from my options and press the update button, it updates the particular field in the table in the database with the value of the selection...
Yes, it did update the data in the table, setting it to a blank (which means the update works)...but like you said...$accessType doesn't hold any values...but I do not understand why that's so, did I code it correctly?
print("<td>
<select id='access' name='accessType' width='15'>
<option value='.$myrow[5].'>Choose Access Level</option>
<option value='NULL'>NULL</option>
<option value='User'>User</option>
<option value='Admin'>Admin</option>
<option value='SysAdmin'>SysAdmin</option>
</select>
</td>");
$accessType=$_POST['accessType'];
I put die(); in many places for testing purposes really...
What I have noticed is that whenever i press the 'submit' button from the searchUser.php page, I get the results in the table as well as the die message...even though I had an 'if' statement with respect to the 'update' button...
OK, I changed it to
$_POST['accessType']
but the die message still shows...
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 'WHERE EmployeeID =114301' at line 1
Ok,
I echoed $q2, and this is what I see:
UPDATE Operators SET accessLevel= WHERE EmployeeID =114301
it seems as though it's not seeing anything for $accessType
Where do I print the query with the dynamic variables? The place where I entered the query with the static variables before was in the MySQL Query Browser...
so I tried the
die (mysql_error())
and this is the error message i got:
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 'WHERE EmployeeID =114301' at line 1
I did try the query in the phpmyadmin/mysql console with static variables though, and it executed properly, it updated correctly, but I will now try the mysql_error() in the die...
Hello there,
My intentions are to enter the employee id in the search page, and have the results displayed below the area to enter the search criteria with the select box and update button( i only want to update 1 field) here are the codes.....
My problem is whenever i enter the employee id in the search box, apart from the results being displayed, the die("Update not successful");
message is also displayed, therefore my update doesn't work...
please help me, i am not sure what else to do (due to my lack of php knowledge)...
:( :S :sad:
SearchUser.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/TAISadministratorPortal.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>TAIS Administrator's Portal</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
.style28 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
color: #006600;
}
.style29 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
-->
</style>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
.style27 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
}
body {
background-color: #CCFFCC;
}
-->
</style>
</head>
<body onload="goforit()">
<table width="200" border="0" align="center">
<tr>
<th colspan="6" scope="col"><img src="images/apBanner2.png" width="962" height="225" /></th>
</tr>
<tr>
<td width="155"><a href="apHome.php"><img src="images/btnHome.png" border="0" /></a></td>
<td width="155"><a href="randomPassword.php"><img src="images/btnResetPassword.png" border="0" /></a></td>
<td width="155"><a href="searchUser.php"><img src="images/btnAccessLevel.png" border="0" /></a></td>
<td width="155"><img src="images/btnDeleteUser.png" /></td>
<td width="327" colspan="2">
<div align="center">
<script>
/*
Live Date Script-
© Dynamic Drive …
Hi All,
I think I'm lost.....
Here's my problem, I have a searchUser.php which allows the user to enter the Employee ID and submit (which searches for the user). The result is displayed from the chunk of code below. I want to allow the user to append a particular field, therefore i added the select to the table...whenever i click the update button, nothing happens....
{
echo"<tr><td>";
print("<center>
<table border='1' width='900'>
<tr align='center' bgcolor='#339900'>
<td><font face='verdana' size='2' color='white'><b>Employee ID</b></font></td>
<td colspan='2'><font face='verdana' size='2' color='white'><b>Name</b></font></td>
<td><font face='verdana' size='2' color='white'><b>Initials</b></font></td>
<td><font face='verdana' size='2' color='white'><b>Username</b></font></td>
<td><font face='verdana' size='2' color='white'><b>Access Level</b></font></td>
<td colspan='2'><font face='verdana' size='2' color='yellow'><b>Select Access to be Granted and Update</b></font></td>
</tr>");
for($counter=0; $myrow=mysql_fetch_row($result); $counter++)
{
print("<tr>");
foreach($myrow as $key => $value)
print("<td><font face='verdana' size='2'>$value</font></td>");
print("<form action='update.php' method='post'>");
print("<td><select name=accessType width='15'><option value=".$myrow[5].">Choose Access Level</option><option value=NULL>NULL</option><option value=User>User</option><option value=Admin>Admin</option><option value=SysAdmin>SysAdmin</option></select></td>");
}
print("<td><input name='btnUpdate' type='submit' value='Update' /></td>");
print("</tr></table></form></center>");
}
here is the update.php code:
<?php
include("./connect.php");
global $conn;
$accessType = $_POST['accessType'];
$btnUpdate = $_POST['btnUpdate'];
if(isset($btnUpdate))
{
$empNo = $_GET[$myrow[0]];
$q1 = "UPDATE Operators SET accessLevel=".$accessType." WHERE EmployeeID =".$empNo;
$result1 = mysql_query($q1, $conn) or die("Update not successful");
}
?>
Oho....well actualy the image works...it displays on the web page as a confirmation msg to the user that their info was sent....but the email with the link part was the problem....
Ok....well thank you...
Hi Guys and Gals....
Could anyone help me with respect to why when this email is sent, the hyperlink in the message doesn't work?
//send email
$to = $myrow['FirstName'].".".$myrow['LastName']."@petrotrin.com";
$subject = "TAIS Application - New Randomly Generated Password";
$from = "TAIS Application";
$msg = "Dear User ".$myrow['FirstName']." ".$myrow['LastName']." (".$empNo."),\n\nYou have requested that your password be changed due to unforeseen circumstances, and by doing so you acknowledge that you are no longer going to be using the old password.\n\nYour temporary password is: ".$pass."\n\nYou can change your temporary password by clicking the following link and follow the instructions. [B]<a href='resetPassword.php' title='Change Password' target='_blank'>Change Password</a>[/B]\n\nRegards\nTAIS Administration";
$mailsend = mail("$to","$subject","$msg","From: ".$from);
echo $mailsend ? "<img src='images/emailGone.gif' /> Random Password Sent." : "<img src='images/emailNotGone.png' />Random Password Not Sent.";
Well, It's supposed to be a java desktop application that upload/loads the data from the MS Excel file (which is also on the desktop) into the specified table in a MySQL DB...
any guidance???
Hello,
I need some help....I have to create part of an application that uploads an MS Excel file, and stores the data into a MySQL db...and I have no clue where to start...
It is the same, I double checked it, but what I also realized is that the PHP file(which contains the form) is probably the problem, since all I did was replaced my changes on the PHP file with the old copy(the one without the changes)...and it worked, so I think the problem lies in the PHP file...
Thank you for your help though...
P.S. Hey ~S.O.S~, cool pic.....
Hi All,
I am just curious to find out...is there anyone out there who've encountered the same problem or similar...please help me...
I got a working .js file, and I tried to edit the code, when I tested my edit, it doesn't work, since the system is already up and running, I decided to set the code back to the way it was, before I edited it.......now it totally doesn't work, and there is no validation control on the particular field...
can anyone tell me why it doesn't work now, when it was totally working before I edited it....
Hi There,
Can anyone explain to me this line of code? What is it used for? etc.. $HTTP_POST_VARS['command']
The text that I saw it in doesn't explain it...
Hey,
Thank You Petr 'PePa' Pavel, it worked like a charm...
Thanks All..