PHP - Need Coding Help
I have 4 files like attached.... if i clicked on index.php content-1 link... that open templet.php and body load with content-1.txt please helpme Similar TutorialsHi I am beginning the first stages of a tumble log and am having some trouble, this works. <?php $connection = @mysql_connect('localhost','admin','asdf'); if(!$connection) ( die('Could not connect to the server!' .mysql_error()) ) ?> but if I add the following I get an error: <?php $connection = @mysql_connect('localhost','admin','asdf'); if(!$connection) ( die('Could not connect to the server!' .mysql_error()) ) if(!mysql_select_db('tumblelog')) ( die('Could not connect to database') ) ?> This is the error: Quote Parse error: syntax error, unexpected T_IF in E:\AppServ\www\tumblelog\database.php on line 10 I also tried this to solve the problem: <?php $connection = @mysql_connect('localhost','admin','glock123'); if(!$connection) ( die('Could not connect to the server!' .mysql_error()) ) $db = mysql_select_db('tumblelog')) if(!$db) ( die('nope') ) ?> that only gives me this error: Quote Parse error: syntax error, unexpected T_VARIABLE in E:\AppServ\www\tumblelog\database.php on line 9 I have a small mp3 script and its running accurately ...i want to check the mp3 URL before playing it whether the mp3 link active or broken ....how to check the link is active or broken in php thanks I have a sql statement w/c suppose to output only those records w/c has a name of seller. But, it keeps showing all the records. Code: [Select] <?php session_start(); if(isset($_SESSION['name']) || ($_SESSION['contact']) || ($_SESSION['address']) ) { ini_set('display_errors', 0); $name = $_SESSION['name']; $contact = $_SESSION['contact']; $address = $_SESSION['address']; ?> <div id="apDiv1"> <?php echo "Name : $name"; echo "</br>"; echo "Name : $contact"; echo "</br>"; echo "Name : $address"; ?> <div id="apDiv2"> <?php $host="localhost"; $username="root"; $password=""; $db_name="feedbackdb"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM Feedbacks WHERE Seller = $name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"600\" >"; echo "<tr><th>Feedbacks</th><th>From</th><th> To </th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "" .$row['Feedback']."<br></td>"; echo "<td>".$row['From']."<br></td>"; echo "<td>".$row['Seller']."<br></td>"; echo "</tr>"; } } else { echo "<tr><td align=\"center\"> No Feedback</td></tr>"; } ?></div> </div> <?php } else { header("location:loginpage.php");; } ?> Im having trouble making a code for a feedback system. Can anyone help me to make a code like this. I have a table w/c contains -------------------------------------------- | Itemname | Itemprice | Seller | Laptop | 15000 | Name Phone | 5000 | Name ----------------------------------- Then.. i want a code that will query those values.. And have a button : [BUY] and [POST FEEDBACK] after the values. Then after clicking POST FEEDBACK it will show the values of the SELLER name in another page. HELP ME PLS So I put this in the wrong place so ill try again, I need to write a code to add the price of five items with a subtotal, with tax, and then a grand total. What is the best way to do this? Every way I have tried isnt working PLEASEEEEEE HELP!!! Using crimson editor Hi I need some help. I have a page which will show all the result based on the user sign in. And it will show something like this ID | Event Start Date | Event End Date | Event Details 1 19-11-2011 20-11-2011 View Event Details The view event details is a link so when I click on the link, it will link me to the next page (eventDetails.php?id=1) And at eventDetails.php?id=1 page, it would requires user to input whether they will be attending or not and will they be bringing their friend along then submit the form. When I submit, how do I pass all the data from eventDetails.php?id=1 page to confirmation.php page (after submitting)? You might want to refer to the attached coding. All the 2 php pages are working fine but when submit to confirmation.php page, the data are not post over so I didn't attach the confirmation.php page. Thanks Ben Chew [attachment deleted by admin] Is there a way i can make a php code for making a lesson then upload to my made system? Im newbie here. so basically, i need to make an e-learning system that lets the user make a lesson then upload it so that other user can view their made lesson.. Someone help me pls. I'm trying to update a field in my MySQL but instead of updating this makes the field BLANK. my code: $SomeVar = $_POST['finco']; mysql_query("UPDATE c_applicants SET streetz='$cts' WHERE username = '".$SomeVar."'"); $result = mysql_query($query); Hi All I am fairly new to the PHP world so please excuse my ignorance. (I am trying!) Basically I bought a commercially available PHP script and created my own script to work alongside the bought one. What happened then is that the developers of the script I bought released a new version of the software. My script no longer works and is throwing up the following error PHP Fatal error: Using $this when not in object context in C:\wamp\www\classifieds\system\core\System.php on line 175 I've worked out that the script fails on this line, in the new version of the software. $dbhost = System::getSystemSettings('DBHOST'); On review of the commercial script's coding, I noticed that where the old version used the syntax above, the new version uses a syntax as shown below $this->appContext->getSystemSettings('DBHOST'); So I went and modified my script (mismatched.php) to read as follows $dbhost = $this->appContext->getSystemSettings('DBHOST'); But im now getting the following errors PHP Parse error: syntax error, unexpected T_REQUIRE_ONCE, expecting T_FUNCTION in C:\wamp\www\classifieds\admin\mismatched.php on line 5 I'd appreciate any ideas you may have that could help me get my script (mismatched.php) working again. Thanks again Ali this doesn't work. Please help fix this. $result1=mysql_query("SELECT * FROM applicants WHERE username = '$user' AND status = 'PendingXCD'"); if(mysql_num_rows($result1)) { $login = "&err=In progress."; echo($login); } else { $result=mysql_query("SELECT * FROM comp WHERE username = '$user' AND password ='$pass'"); if(mysql_num_rows ($result) == 0) { $login = "&err=Please retry."; echo($login); } else { $row = mysql_fetch_array($result); $user=$row['user']; $pass=$row['pass']; $login = "$user=" . $user . "$pass=" . $pass . "&err=Successful."; echo($login); } ?> How can I get it so the following work: echo utf8_decode($xml->healings[0]->$xmla[0]->descrip[0]); // NOT work echo utf8_decode($xmlb); // NOT work <?php $xml = simplexml_load_file('extra.xml'); $xmla = "test"; $xmlb = "$xml->healings[0]->".$xmla."[0]->descrip[0]"; echo utf8_decode($xml->healings[0]->test[0]->descrip[0]); // works echo utf8_decode($xml->healings[0]->$xmla[0]->descrip[0]); // NOT work echo utf8_decode($xmlb); // NOT work ?> Im making an E-learning system that when Student registers the Teacher will approve.. So i've got here a code that outputs all those who registered via Checkbox. Code: [Select] <form name="formapprove" method="POST" action="valval3.php" > <div id="apDiv12"><input type="image" src="images/Approve.png" name="approve" value="approve" width="170" height="35" border="0" > </div> <div id="apDiv11"> <input type="image" src="images/reject.png" name="reject" width="170" height="35" border="0" value="reject"> </div> <div id="apDiv14">'; $host="localhost"; $username="root"; $password=""; $db_name="dbreg"; $tbl_name="account"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"400\" >"; echo "<tr><th>List of Student to be approve</th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "<input type='checkbox' name='list[]' value='".$row['Username']."'>".$row['famname'].",".$row['gname']. ",".$row['mname']. ".<br/></td>"; echo "</tr></input>"; } } else { echo "<tr><td align=\"center\"> No Student to be Approve / Reject </td></tr>"; } echo' </form> Then the file "valval3.php" will be the one that will save the variables in my database.. Code: [Select] <?php session_start(); if(isset($_SESSION['uname2']) || ($_SESSION['section'])){ $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } if(isset($_POST['approve_x'], $_POST['approve_y'])) { mysql_select_db("dbreg", $con); $uname = $_SESSION['uname2']; $sec = $_SESSION['section']; $sql="SELECT * FROM account where sec='$sec'"; $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $fullname = "" .$row['famname']. ", " .$row['gname']. " " .$row['mname']. "."; } foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE sec='$sec'"; } $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $username = $row['Username']; $password = $row['Password']; $gname = $row['gname']; $mname = $row['mname']; $famname = $row['famname']; $sec = $row['sec']; $studnum = $row['studnum']; $fullname = "" .$row['famname']. ", " .$row['gname']. " " .$row['mname']. "."; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $gname = stripslashes($gname); $famname = stripslashes($famname); $gname = mysql_real_escape_string($gname); $famname = mysql_real_escape_string($famname); $mname = stripslashes($mname); $mname = mysql_real_escape_string($mname); foreach ($_POST['list'] as $checkbox) { mysql_query("INSERT INTO dbaccount (Username, Password, gname, famname, mname, sec, studnum, fullname) VALUES ('$username', '$password', '$gname', '$famname', '$mname', '$sec', '$studnum', '$checkbox')") or die(mysql_error); mysql_query("DELETE FROM account WHERE sec='$sec'") or die(mysql_error); } echo '<script type="text/javascript"> {alert("Approved!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; mysql_close($con); } } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } }elseif(isset($_POST['reject_x'], $_POST['reject'])) { mysql_select_db("dbreg", $con); foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE sec='$sec'"; } $result=mysql_query($sql); if(mysql_num_rows($result)) { foreach ($_POST['list'] as $checkbox) { mysql_query("DELETE FROM account WHERE sec='$sec'") or die(mysql_error); } echo '<script type="text/javascript"> {alert("Rejected!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } } else { header("location:failunautho.php");; } ?> I tested my codes. Its only working if theres only 1 user registered ( which means one checkbox would appear in page) But when i tested to have 3 users registered and not yet approve, There would be an error saying.. Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 49 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 49 $username = mysql_real_escape_string($username); <-- line #49 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 50 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 50 $password = mysql_real_escape_string($password); <-line #50 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 54 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 54 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 55 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 55 $gname = mysql_real_escape_string($gname); <-line #54 $famname = mysql_real_escape_string($famname); <-line# 55 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 58 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 58 mname = mysql_real_escape_string($mname); <-line #58 Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 64 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 64 mysql_error VALUES ('$username', '$password', '$gname', '$famname', '$mname', '$sec', '$studnum', '$checkbox')") or die(mysql_error) <-line #64 Then still it saves 3 variables.. but all the same. Hope Someone could help me .. Hello guys it's me again. I have not posted a question in awhile so I am glad to be on PHPFreaks again. Anyways here is my question, I have simple "Filter By" or "Refine By" script I am developing. It's foundation is primarily database (MySQL) and does not use XML or other table files. This script simply add's filtered array ("objects") to the url as the customer filters his/her search. An example, $attributeCodes("processor_type","color","memory"); // These arrays are defined and built from the database on the time of the request. So they are automatically updated. The above array is used in an if/and/or statement to look for these attribute codes. If it finds it and it has a value it then refines the MySQL query to look for products with the said attribute code. Now that we have the basics out there of how it works I am at the part where it confuses me. I give the user the ability to filter his/her search, however I want the user to be able to remove these filters separately if wanted. So for example the customer filters, Domain.com/search/productsearch.php?catId=112&processor_type=AMD&memory=2gb The customer does not need the memory filter and wishes to remove that specific item or vice-verse he/she does not want to search by processor_type. How is it that I can remove specifically one attribute and its value from the URL? So the url will then look like, Domain.com/search/productsearch.php?catID=112&processor_type=AMD or Domain.com/search/productsearch.php?catID=112&memory=2gb Any help would be great. Or if you have any suggestions on a different method to filter by attributes products. Suggestions and criticism are welcome. Please do not be shy or modest when it comes to giving me advice as I am trying to learn efficiently. - Travis I'm unable to update the table. Could someone tell me why? $dfield1 = mysql_real_escape_string($field1); $dfield2 = mysql_real_escape_string($field2); $dfield3 = mysql_real_escape_string($field3); $dfield4 = mysql_real_escape_string($field4); $result =sprintf("SELECT * FROM db1 WHERE username ='%s'", $dfield1); $resultf = mysql_query($result); if (mysql_num_rows ($resultf) > 0){ $register = "&err=Not Available. Retry."; echo($register); } else { mysql_query("INSERT INTO db1 (name, birthday, street, phone) VALUES ('$dfield1', '$dfield2', '$dfield3', '$dfield4')"); $register = "Successful."; echo($register); } Hello, My wife wants to set up a PHP Powered Demerit System at her school. I have basic PHP and MySQL skills. Basically she wants a web interface where a student logs in with Student Number and Password. Demerits and merits accrue to the students as below: Coming late to school, 1 Demerit Handing an assignment late, 2 Demerits No Demerits in 3 months equals 1 Merit assigned Student suspended after 6 / more Demerits Parent / Gaurdian emailed The student will see the table below once logged in: Student Name Student ID Date Action Demerit Merit Total A123 2012/02/26 Late Sign In 1 0 1 2012/02/28 Late Assignment 1 0 2 2012/05/29 3 month Merit earned 0 1 1 2012/06/08 Late Assignment 2 0 3 2012/06/10 Late Assignment 2 0 5 2012/06/12 Late Assignment 2 0 7 Student suspended Send email to parent/gaurdian I would really appreciate any help you can offer in terms of what PHP code to include in the HTML doc as well as how many MySQL Tables to setup as well as where to store which data? Thanks, Ishvir Hi,
I need to change 'Products with stock >60' to 'there are no products that have more than 60 in stock' in php script. I am not sure how to do the coding to change this in php script. If someone could help me within the next hour or two that would be amazing. thank you
<?php require_once('Connections/check_mag.php'); ?> what goes wrong with that code and when i push a link for another post in my page nothing changes? where is the wrong plzzzzz help i cant understand im looking for this for 5 days and i cant find the mistake pllzzzzzzzz heellp . if you write your cooment please give me details because i cant understand very well everything thanx for everythin:) <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_check_mag, $check_mag); $query_getArchives = "SELECT DISTINCT DATE_FORMAT(news.updated, '%M %Y') AS archive, DATE_FORMAT(news.updated, '%Y-%m') AS link FROM news ORDER BY news.updated DESC "; $getArchives = mysql_query($query_getArchives, $check_mag) or die(mysql_error()); $row_getArchives = mysql_fetch_assoc($getArchives); $totalRows_getArchives = mysql_num_rows($getArchives); mysql_select_db($database_check_mag, $check_mag); $query_getRecent = "SELECT news.post_id, news.title FROM news ORDER BY news.updated DESC LIMIT 10 "; $getRecent = mysql_query($query_getRecent, $check_mag) or die(mysql_error()); $row_getRecent = mysql_fetch_assoc($getRecent); $totalRows_getRecent = mysql_num_rows($getRecent); mysql_select_db($database_check_mag, $check_mag); $query_getDisplay = "SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT 2 "; $getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error()); $row_getDisplay = mysql_fetch_assoc($getDisplay); $totalRows_getDisplay = mysql_num_rows($getDisplay); $var1_getdisplay2 = "-1"; if (isset($_GET['archive'])) { $var1_getdisplay2 = $_GET['archive']; $query_getdisplay = sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE DATE_FORMAT(news.updated, '%%Y-%%m') = %s ORDER BY news.updated DESC ", GetSQLValueString($var1_getdisplay2, "text")); }elseif (isset($_GET['post_id'])) { $var2_getdisplay3 = $_GET['post_id']; $query_getdisplay= sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE news.post_id = %s ", GetSQLValueString($var2_getdisplay3, "int")); }else{ $query_getDisplay = "SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT 2 ";} $getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error()); $row_getDisplay = mysql_fetch_assoc($getDisplay); $totalRows_getDisplay = mysql_num_rows($getDisplay); ?> <!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/totemp.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="index, follow" /> <meta name="keywords" content="Σύλλογος Ηπειρωτών Πιερίας,Χορευτικός Σύλλογος,Χορός,Χορευτής,Ήπειρος,SYLLOGOS HPIROTON PIERIAS,pieria,ΠΙΕΡΙΑ" /> <meta name="description" content="Σύλλογος Ηπειρωτών Πιερίας,Χορευτικός Σύλλογος,Χορός,Χορευτής,Ήπειρος,SYLLOGOS HPIROTON PIERIAS,pieria,ΠΙΕΡΙΑ" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Check Magazine</title> <!-- InstanceEndEditable --> <link href="styles/check_cs5.css" rel="stylesheet" type="text/css" /> <link href="styles/check_menu.css" rel="stylesheet" type="text/css" /> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> </head> <body> <!-- DO NOT MOVE! The following AllWebMenus linking code section must always be placed right AFTER the BODY tag--> <!-- ******** BEGIN ALLWEBMENUS CODE FOR menu ******** --> <script type="text/javascript">var MenuLinkedBy="AllWebMenus [4]",awmMenuName="menu",awmBN="798";awmAltUrl="";</script><script charset="UTF-8" src="menu.js" type="text/javascript"></script><script type="text/javascript">awmBuildMenu();</script> <!-- ******** END ALLWEBMENUS CODE FOR menu ******** --> <div id="container"> <h1>Check Magazine: Fashion and Lifestyle</h1> <div id="eikona"><img src="images/silogos.jpg" width="1211" height="134" alt="silogos" /></div> <div id="bara"> <p> </p> </div> <!-- InstanceBeginEditable name="EditRegion3" --> <div id="blog"> <p> </p> <div id="archive"> <h3>Archives</h3> <ul><?php do{?> <li><a href="news1.php"> <a href="news1.php"><?php echo $row_getArchives['archive'];?></a><a></li> <?php } while ($row_getArchives=mysql_fetch_assoc($getArchives));?> </ul> </div> <div id="recent"> <h3>RECENT</h3> <ul> <?php do { ?> <li><a href="news1.php?post_id=<?php echo $row_getRecent['post_id']; ?>"><?php echo $row_getRecent['title']; ?></a></li> <?php } while ($row_getRecent = mysql_fetch_assoc($getRecent)); ?> </ul> </div> <div id="blog_posts"> <?php do { ?> <h2><?php echo $row_getDisplay['title']; ?></h2> <p>Uploaded on <?php echo $row_getDisplay['formatted']; ?></p> <p><?php echo nl2br($row_getDisplay['blog_entry']); ?></p> <?php } while ($row_getDisplay = mysql_fetch_assoc($getDisplay)); ?> </div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <!-- InstanceEndEditable --> <p> </p> </div> </body> <!-- InstanceEnd --></html> <?php mysql_free_result($getArchives); mysql_free_result($getRecent); mysql_free_result($getDisplay); ?> I am self taught and am trying very hard to get a log in page to work. The way i want it to work is that when they log in it uses a url stored in the database for their account. But i am having some much trouble working out a code that works and this is all i got: <?php include ('connection.php'); $username=$_POST['username5']; $password=$_POST['password5']; $query="SELECT password FROM merchants WHERE username = '$_POST(username5)'"; if ($password == $query) { $url = "SELECT url FROM merchants WHERE username = '$_POST(username5)'"; header("Location: $url"); } else { echo urgh } ?> I know this form doesn't really work, but the FTP part *should* work. I select a file, and click upload, Chrome shows the file is uploading and gets to 100% then fails. I'm getting "File Upload Failed!" on line 112 every time, but I can't seem to figure out why. I'm hoping a pair of expert eyes can spot it quickly. Code: [Select] Upload A File: <form enctype="multipart/form-data" action="File_Upload.php" method="POST"> <table> <tr><td>Song Title:</td><td><input></input></td></tr> <tr><td>Singer/Group:</td><td><input></input></td></tr> <tr><td>Album Name:</td><td><input></input></td></tr> <tr><td>Video Link:</td><td><input></input></td></tr> <tr><td>Category:</td><td><input></input></td></tr> <tr><td>Choose a file to upload:</td><td><input name="uploadedfile" type="file" /></td></tr> <tr><td><input type="submit" value="Upload File" /></td></tr> </table> </form> <?php //********************************************************************************************** echo "Please wait while we attempt to upload your file...<br><br>"; //********************************************************************************************** $target_path = "temp_uploads/"; $flag = 0; // Safety net, if this gets to 1 at any point in the process, we don't upload. $filename = $_FILES['uploadedfile']['name']; $filesize = $_FILES['uploadedfile']['size']; $mimetype = $_FILES['uploadedfile']['type']; $filename = htmlentities($filename); $filesize = htmlentities($filesize); $mimetype = htmlentities($mimetype); $target_path = $target_path . basename( $filename ); if($filename != ""){ echo "Beginning upload process for file named: ".$filename."<br>"; echo "Filesize: ".$filesize."<br>"; echo "Type: ".$mimetype."<br><br>"; } //First generate a MD5 hash of what the new file name will be //Force a MP3 extention on the file we are uploading $hashedfilename = md5($filename); $hashedfilename = $hashedfilename.".mp3"; //Check for empty fileif($filename == ""){$error = "No File Exists!"; $flag = $flag + 1; //Now we check that the file doesn't already exist. $existname = "temp_uploads/".$hashedfilename; if(file_exists($existname)){ if($flag == 0){ $error = "Your file already exists on the server! Please choose another file to upload or rename the file on your computer and try uploading it again!"; } $flag = $flag + 1; } //Whitelisted files - Only allow files with MP3 extention onto server... $whitelist = array(".mp3"); foreach ($whitelist as $ending) { if(substr($filename, -(strlen($ending))) != $ending) { $error = "The file type or extention you are trying to upload is not allowed! You can only upload MP3 files to the server!"; $flag++; } } //Now we check the filesize. If it is too big or too small then we reject it //MP3 files should be at least 1MB and no more than 25 MB if($filesize > 26214400){ //File is too large if($flag == 0){ $error = "The file you are trying to upload is too large! Your file can be up to 25 MB in size only. Please upload a smaller MP3 file or encode your file with a lower bitrate."; } $flag = $flag + 1; } if($filesize < 1048600){ //File is too small if($flag == 0){ $error = "The file you are trying to upload is too small!Your file has been marked as suspicious because our system has determined that it is too small to be a valid MP3 file.Valid MP3 files must be bigger than 1 MB and smaller than 25 MB."; } $flag = $flag + 1; } //Check the mimetype of the file if($mimetype != "audio/x-mp3" and $mimetype != "audio/mpeg"){ if($flag == 0){ $error = "The file you are trying to upload does not contain expected data.Are you sure that the file is an MP3?"; }$flag = $flag + 1; } //Check that the file really is an MP3 file by reading the first few characters of the file $f = @fopen($_FILES['uploadedfile']['tmp_name'],'r'); $s = @fread($f,3); @fclose($f); if($s != "ID3"){if($flag == 0){ $error = "The file you are attempting to upload does not appear to be a valid MP3 file.";}$flag++; } //All checks are done, actually move the file... if($flag == 0){ if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { //Change the filename to MD5 hash and FORCE a MP3 extention. if(@file_exists("../music/".$filename)){ //Rename the file to an MD5 version rename("uploads/".$filename, "uploads/".$hashedfilename); echo "The file ".basename( $filename )." has been uploaded. Your file is <a href='uploads/$hashedfilename'>here</a>."; } else{ echo "There was an error uploading the file, please try again! (1)"; } } else{ echo "There was an error uploading the file, please try again! (2)"; } } else { echo "File Upload Failed!<br>"; if($error != ""){ echo $error; } } ?> Hi guys,
I am needing some help of how to place the coding as I can not get it to work.
--
Basically I am building a website for the local motorclub and want some code that will "add up" each persons results.
Here is what I have come up with but it does not work;
<?php $total = mysql_fetch_array("SELECT cat1 + cat2 + cat3 + cat4 + cat5 + cat6 AS total FROM results") ?> <?php $cautotest_results = mysql_query("SELECT * FROM results WHERE cat ='1' ORDER BY cattotal DESC"); if(mysql_num_rows($cautotest_results) == '') { echo "<p>No Results Available."; } else { echo "<table width=\"800\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" class=\"greywritinglight\" align=\"center\"> <tr align=\"center\"> <td>Competitor</td> <td>Vehicle</td> <td>Class</td> <td>Skipton</td> <td>Weston</td> <td>King Bros</td> <td>Normans</td> <td>Norwood</td> <td>Uniroyal</td> <td>Total</td> </tr>"; $x=1; while($results_row = mysql_fetch_array($cautotest_results)) { if($x%2): $rowbgcolor = "#FFFFFF"; else: $rowbgcolor = "#EEEEEE"; endif; echo "<tr align=\"center\" bgcolor=\"" .$rowbgcolor. "\">"; echo "<td>" . $results_row['competitor'] . "</td>"; echo "<td>" . $results_row['catvehicle'] . "</td>"; echo "<td>" . $results_row['catclass'] . "</td>"; echo "<td>" . $results_row['cat1'] . "</td>"; echo "<td>" . $results_row['cat2'] . "</td>"; echo "<td>" . $results_row['cat3'] . "</td>"; echo "<td>" . $results_row['cat4'] . "</td>"; echo "<td>" . $results_row['cat5'] . "</td>"; echo "<td>" . $results_row['cat6'] . "</td>"; echo "<td>" . $total . "</td>"; echo "</tr>"; $x++; } echo "</table>"; } ?>Its the top line of coding... and the echo .total. at the bottom. If you could please correct me I would be ever so grateful. If you need more info please just ask. All help is appreciated. JTM. Edited by JTM, 17 August 2014 - 12:45 AM. |