
Gilly79
Members-
Posts
34 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Gilly79's Achievements

Member (2/5)
0
Reputation
-
Thanks for that - I have read the titorial and i think im coding it correctley now <?php $con = mysql_connect("mysql9.000webhost.com","a8346733_shp","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); ?> <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="userfile" type="file" id="userfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> <?php if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $query = "INSERT INTO upload (name, size, type, content ) VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; } ?> ********** The mysql_select_db("my_db", $con); - THE"my_db" REFERS TO THE DATABASE I HAVE SELECTED IN THE $con INSTRUCTION..? I wrote in capitals to differentiate from the code.. I still have the same error im afraid Error, query failed After i learnt to code the Mysql error - I get the following message: No database selected So I arn't selecting the database -- but i do not know what is incorrect with my select command Thank you for your patience
-
Ahhh do i have to select the database before i insert into?!? Appologies I know this is going to be a very stupid question for the experts.. Is there a good tutorial anybody could recommend for me?!?
-
Hello Do I need to set anything at the php side?!? And Mysql privlidges blocking this??!?
-
I do appologise - i will change the password etc now.. thank you for this - it is only my test harness but i appreciate what you are saying and thank you I recived the same error message: Error, query failed And there is nothing in the database I have read the sticky and i sorry that my reply didn't detail this
-
no that didn't work im afriad
-
I havn't coded in over a year so i do appologise for the basic question I have written/borrowed some code which is attempting to perform an image upload.. I struggled with this at uni aswell!! doh! And basically it will not upload to server.. This is the code <?php $con = mysql_connect(******); if (!$con) { die('Could not connect: ' . mysql_error()); } ?> <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="userfile" type="file" id="userfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> <?php if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $query = "INSERT INTO upload (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; } ?> This is the error displayed in the browser... Error, query failed And this is the mysql create table dump upload CREATE TABLE `upload` ( `id` int(11) NOT NULL auto_increment, `name` varchar(30) collate latin1_general_ci NOT NULL, `size` varchar(30) collate latin1_general_ci NOT NULL, `type` varchar(30) collate latin1_general_ci NOT NULL, `content` longblob NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ Is there anyone that can help - I have done a search but not really sure where my error is - Do I need to specify the actual image table in the Mysql conect comand?!? Online URL = http://gillystestharness.comxa.com/ Thans in advance
-
Hi - this is still not working - Is it something im doing on the page elsewhere preventing it working?? Ive even not hidden the form so I can tell if it is being populated or not the fields subject and report message are not being populated in the form - The only fields being populated in the form are the vars being passed from the previous calling page I cant seem to reference anything from my select statement... below is the code <?php // Start the session require_once('startsession.php'); // Insert the page header $page_title = 'View Selcted Student Report Report'; require_once('header.php'); // ========== SCOTT ============== //Include the connection details, open $connection and select database //include ("connection.php"); require_once('connectvars.php'); //vars $user_id = $_SESSION['user_id']; $Report_ID = $_GET['Report_id'] ; $user_idp = $_GET['user_idp'] ; $sfirst_name = $_GET['sfirst_name'] ; $ssurname = $_GET['ssurname'] ; $Overall_Grade = $_GET['Overall_Grade'] ; $Date = $_GET['Date'] ; echo $user_id; echo $Report_ID; echo $user_idp; echo $sfirst_name; echo $Overall_Grade; echo $Date; echo $ssurname; ?> <?php //Prepare query $query = "SELECT Student_Reports.Report_ID, Student_Reports.Subject, Student_Reports.Overall_Grade, Student_Reports.Report_Message, parent_student.parent_id, parent_student.student_id, student.first_name, student.surname, student.student_id, parent.parent_id, parent.first_name, parent.surname FROM Student_Reports, parent_student, student, parent WHERE Student_Reports.Report_ID = '$Report_ID' AND student.user_id = '$user_idp' AND parent.user_id = '$user_id' AND parent_student.parent_id = '$user_id' "; // execute query $result = mysqli_query($dbc,$query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysqli_num_rows($result)>0) { echo "<table border=1>\n<tr>" . "<th>Reportid</th>" . "<th>Overall_Grade</th>" . "<th>first_name</th>" . "<th>Surname</th>" ; // "<th>Message</th>". // "<th>Delete</th>". // "<th>View</th>". // "<th>Reply</th>". while ($row = @ mysqli_fetch_array($result)) { //while($row = mysql_fetch_row($result)) { echo "<tr>"; echo "<td>".$row["Report_ID"]."</td>"; echo "<td>".$row["Overall_Grade"]."</td>"; echo "<td>".$row["first_name"]."</td>"; echo "<td>".$row["surname"]."</td>"; echo "<tr><th colspan='4'>Date Report Written:</th></tr>" ; echo "<tr><td colspan='4'>$Date</td>"; echo "<tr><th colspan='4'>Student Name</th></tr>" ; echo "<tr><td colspan='2'>$sfirst_name</td>"; echo "<td colspan='2'>$ssurname</tr></td>"; echo "<tr><th colspan='4'>Subject</th></tr>" ; echo "<tr><td colspan='4'>".$row["Subject"]."</td></tr>"; echo "<tr><th colspan='4'>Report_Message</th></tr>" ; echo "<tr><td colspan='4'>".$row["Report_Message"]."</td></tr>"; // echo "<td>".$row["username"]."</td>"; // echo "<td>".$row["MessageTo"]."</td>"; // echo "<td>".$row["Subject"]."</td>"; // echo "<td>".$row["Message"]."</td>"; echo "</tr>"; } echo "</table>"; } else { // no // print status message print "No Reports To View"; } ?> <p><form enctype="multipart/form-data" method="post" action="test2.php"> <input name="Subject" id="Subject" value="<?php echo $row['Subject']; ?>" /> <input name="Report_Message" id="Report_Message" value="<?php echo $row['Report_Message']; ?>" ></input><br /> <input name="Date" id="Date" value="<?php echo $Date; ?> "></input><br /> <input name="Overall_Grade" id="Overall_Grade" value="<?php echo $Overall_Grade; ?> "></input><br /> <input name="sfirst_name" id="sfirst_name" value="<?php echo $sfirst_name; ?> "></input><br /> <input name="ssurname" id="ssurname" value="<?php echo $ssurname; ?> "></input><br /> <input name="user_idp" id="user_idp" value="<?php echo $user_idp; ?> "></input><br /> <p> <label>View Report as PDF <input type="submit" name="submit" id="button" value="submit" /> </label></p> </form>
-
Hi - I have the form part covered but the solution you gave regarding the <input type="text" name="Report_Message" id="Report_Message" value="<?php echo $row['Report_Message']; ?>" /> dosn't work...? could it be something else im doing?
-
Hello Im re-wording the previous post i did! Im doing a Select on mysql database - Im displaying this in a table however i also want the value to be in a hidden form which passes variables to another page I do not know how to display .$row["Report_Message"]. in a form that i have specified at the foot of my page.. Currently i have <input name="Report_Message" id="Report_Message" value="<?php echo $row['Report_Message']; ?>" ></input><br /> yet this is not working - any ideas please its doing my sweede in!! Many thanks page attatched.. [attachment deleted by admin]
-
Hi everyone - Im having some real issues when trying to code. My issue is im returning values from a my sql database but i need to put the returned values into a hidden form (which im passing to a fpdf) I want to get the field Report_Message into a form.. However I will have to use the field I have returned from my database as for some reason it is not passing the var from its sending php page... At the moment it is set up as if I am using the $Report_Message var - however this is not working... Please see the attatched file - I cant get the right syntax it seems [attachment deleted by admin]
-
Hello guys Im trying to export values I have returned from a database and put them onto a PDF doument. I can print the static text however passing variables is an issue.. ..One of my errors is im trying to display a message up to 500 words however it only outputs the first word... Are there any tutorials for variables as i can only find the easy ones on the fpdf website.. Ive attached a file to show what im trying to achive.. [attachment deleted by admin]
-
Hello Im really struggling to remember how to display returned PHP. I always seem to display my returned variables in tables and nothing else... I need to do a report with my returned PHP so a table is out of the question - can anyone tell me some display commands or some web links to code displays to help? Also I need ti be able to export this report to a PDF - I know thats not php - any ideas what controls somthing like that?? Thank you so much
-
legend!!! its working!!
-
hi just thinking about it - is it my sql command $query = "DELETE FROM messages WHERE MessageNo IN ($array)"; as the array is working... the error message shows the message number [delete] => Array ( [0] => 7 [1] => 8 ) (i selected message 7 & 8 to be deleted...) shouldn't the sql have an equals in?
-
i see what you have done with the Class etc but it didn't work for me - the page didn't even load with your previous example - im just checking a couple of bits though that i may need to include that are specific to the website