Jump to content

CageyJ0nnY

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by CageyJ0nnY

  1. I have tried the code above, but i am getting this error message? I dont have a clue what i am doing wrong (im new to this)? Array ( [name] => img.jpg [type] => image/jpeg [tmp_name] => /tmp/php1X7FhM [error] => 0 => 2218 ) FileX jpg Warning: move_uploaded_file(upload/img.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/jjennings3/jjennings3.bimserver2.com/upload2.php on line 18 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php1X7FhM' to 'upload/img.jpg' in /home/jjennings3/jjennings3.bimserver2.com/upload2.php on line 18 Sorry, there was a problem uploading your file. # Back thanks Jonny
  2. I have tried inserting the following script after the login is succesfull part of the script, but i keep getting an error message. any ideas? header("location: http://jjennings3.bimserver2.com/siteadmin.php"); exit();
  3. thats great! thanks for the help, what i need though is if the password / username is correct for it to take me to another page. would i have to set this up using an if statement? cheers Jonny
  4. wow, which bits are ment to go where? and i am still ment to connect with the database in both the form and php pages? thanks Jonny
  5. i have made a html form to upload a picture to webspce, it links to a php page that does the uploading and gives a message depending on if the image was successfully uploaded or not. I keep getting the error message and i cant figure out why. please help. here is the form: <?php $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet8'); mysql_select_db('jjennings3db', $conn); ?> <html> <head> <title>Picture Upload</title> </head> <body> <form enctype="multipart/form-data" action="http://jjennings3.bimserver2.com/upload2.php" method="POST"> <p><input type="hidden" name="MAX_FILE_SIZE" value="100000"> Send this file: <input name="filename" type="file"></p> <p>Name for uploaded file: <input name="filename" type="text" id="filename" value="picture.jpg"></p> <p><input type="submit" value="Send File"></p> </form> <p><a href = "http://jjennings3.bimserver2.com/home-ltd.php"></p> <li>Back</li> </a> </body> </html> and here is the php page: <?php $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet4243'); mysql_select_db('jjennings3db', $conn); $filename = ('$_POST[filename]'); $uploaddir = '/home/jjennings3/jjennings3.bimserver2.com/'; $uploadfile = $uploaddir . $filename; if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.<br>"; echo "Its name is <a href=$filename>$filename</a>"; } else { echo "There was an error."; } ?> <html> <head> <title>Imperial to Metric</title> </head> <body> <p><a href = "http://jjennings3.bimserver2.com/upload.php"></p> <li>Back</li> </a> </body> </html> any help would be apprieciated Jonny
  6. sorry i should have posted the new code up here because of the changes i have made here it is: <?php if ((!$_POST[username]) || (!$_POST[password])) { header("location: http://jjennings3.bimserver2.com/userlogin.html"); exit; } $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet557'); mysql_select_db('jjennings3db', $conn); $sql = "SELECT * username FROM login WHERE username = ('', '$_post[username]' AND password = '$_POST[password]')"; $result = mysql_query($sql,$conn); if (mysql_num_rows($result) ==1) { $username = mysql_result($result, 0, 'username'); setcookie("auth", "1", 0, "/", "jjennings3.bimserver2.com/siteadmin.php", 0); $display_block = "<p>$username is authorised!</p> <p>authorised users' menu: <ul> <li><a href=<\"jjennings3.bimserver2.com/siteadmin.php\">site admin</a> </ul>"; } else{ header ("location:http://jjennings3.bimserver2.com/userlogin.html"); exit; } ?> <html> <head> <title>User Login</title> </head> <body> </ echo "$msg"; ?> </body> </html> i dont know weahter your suggestion would still apply (im very new to all this) thanks for the help
  7. I have managed to iron out some of the problems, but the loop keeps sending me back to the log on screen, which leads me to believe that the log on details are not correct. can anyone see where i am going wrong? Jonny
  8. i have created a form that allows a user to enter a username and password. I also have these fields set up in a database which the page links to. I keep getting a timeout error about cookies? I can figure out where i am going wrong? can anyone see the problem? <?php if ((!$_POST[username]) || (!$_POST[password])) { header("location: http://jjennings3.bimserver2.com/userlogin.php"); exit; } $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet68474321'); mysql_select_db('jjennings3db', $conn); $sql = "select f_name from login where username = ('$_post[jonathan]') AND password = password('$_POST[jonathan]')"; $result = mysql_query($sql,$conn); if (mysql_num_rows($result) ==1) { $f_name = mysql_result($result, 0, 'f_name'); setcookie("auth", "1", 0, "/", "jjennings3.bimserver2.com/siteadmin.php", 0); $display_block = "<p>$f_name is authorised!</p> <p>authorised users' menu: <ul> <li><a href=<\"jjennings3.bimserver2.com/siteadmin.php\">site admin</a> </ul>"; }else{ header ("location:http://jjennings3.bimserver2.com/userlogin.html"); exit; } ?> <html> <head> <title>User Login</title> </head> <body> </ echo "$msg"; ?> </body> </html> thanks Jonny
  9. I have changed it to what you suggested but it still wont work =[, im at a loss. thanks for the help
  10. Hello, I cannot figure out how to populate a text box with the result from an array?? The idea is that this is an update form, so the user can amend a property. Heres my first attempt that doesnt work: <?php $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet688468845'); mysql_select_db('jjennings3db', $conn); $id = mysql_real_escape_string($_GET[id]); $sql = "SELECT PropertyName, Location, SalePrice FROM tblProperties WHERE id={$id}";$result1 = mysql_query($sql, $conn); $updateproperty = mysql_fetch_array($result1); ?> <html> <head> <title>Update a Property</title> </head> <body> <form method="post" action="http://jjennings3.bimserver2.com/siteadmin2.php"> <p>Property Name: <input name= <?php echo $updateproperty['PropertyName']; ?> type="text"></p> <p>Location: <input name="Location" type="text"></p> <p>No of Bedrooms: <input name="NoofBedrooms" type="text"></p> <p>Property Price: <input name="Saleprice" type="text"></p> <p>Let Price:<input name="LetPrice" type ="text"></p> <p>Garden Size: <input name="GardenSize" type ="text"></p> <p><input type="submit" name="Submit" value="Update Record"></p> <p><a href = "http://jjennings3.bimserver2.com/update-main.php"></p> <li>Back</li> </form> </body> </html> Thanks for looking Jonny
  11. I have created an array that stores values in a table. I do not know why the values are not being stored in the table but rather outside of it. here is the code: <?php $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet5646546541'); mysql_select_db('jjennings3db', $conn); $sql = "SELECT * FROM tblProperties WHERE id=".$_GET[id]; $result1 = mysql_query($sql, $conn); $array1 = mysql_fetch_array($result1); ?> <html> <head> <title>Properties</title> </head> <body> <table width="640" border="2" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="3" align="center"><h1>Property</h1></td> </tr> <tr> <td align="left" valign="top"><strong>Address:</strong></td> <td align="left" valign="top">PropertyName</td> <td rowspan="2" align="center"valign="middle">book cover picture</td> <?php echo '$array1[PropertyName]'; ?> </tr> <tr> <td align="left" valign="top"><strong>Location:</strong></td> <td align="left" valign="top">Location</td> <?php echo '$array1[Location]'; ?> </td> <tr> <td align="left" valign="top"><strong>Property Price:</strong></td> <td align="left" valign="top">SalePrice</td> <?php echo '$array1[salePrice]'; ?> </td> <tr> <td colspan="3" align="center" valign="top"><a href="http://jjennings3.bimserver2.com/links.php">back to list of Properties</a> </td> </tr> </table> </body> </html> any help would be appreciated Jonny
  12. Im relativley new to PHP so all this is a little confusing 8-S, i problably need what you just said to be translated into lemans terms.... thanks for the help
  13. Hello, i have a database an i am trying to insert records using PHP and HTML. I keep getting this error: Invalid query: Column count doesn't match value count at row 1 this is becuase i jhave told it to give me an error message but i cant find what the problem is... here is the HTML: <html> <head> <title>Insert a Property</title> </head> <body> <form method="post" action="http://jjennings3.bimserver2.com/siteadmin2.php"> <p>Property Name: <input name="PropertyName" type="text"></p> <p>Location: <input name="Location" type="text"> </p> <p>Property Price: <input name="Saleprice" type="text"></p> <p>Let Price:<input name="LetPrice" type ="text"></p> <p>Garden Size: <input name="GardenSize" type ="text"></p> <p><input type="submit" name="Submit" value="Insert Record"></p> <p><a href = "http://jjennings3.bimserver2.com/home-page.php"></p> <li>Back</li> </form> </body> </html> and here is the PHP it links to: <?php $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet83478345'); mysql_select_db('jjennings3db', $conn); $sql = "INSERT INTO tblProperties values ('', '$_POST[PropertyName]', '$_POST[Location]', '$_POST[salePrice]', '$_POST[LetPrice]', '$POST[GardenSize]')"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } else { echo "Record Inserted. Would you like to <a href=\"lecture09example3.php\">view the full list of books</a> or <a href=\"lecture09example1.php\">insert another</a>?"; } ?> any help would be appriciated Jonny
  14. I have a site linked to a database. When uploading an image i get my own error message in return. Because of this i know the script works but that there is an error in there somewhere. Here is the HTML page: <form enctype="multipart/form-data" action="http://jjennings3.bimserver2.com/upload2.php" method="POST"> <p><input type="hidden" name="MAX_FILE_SIZE" value="50000"> Send this file: <input name="filename" type="file"></p> <p>Name for uploaded file: <input name="filename" type="text" id="filename" value="picture.jpg"></p> <p><input type="submit" value="Send File"></p> </form> <p><a href = "http://jjennings3.bimserver2.com/home-page.php"></p> <li>Back</li> </a> </body> </html> and here is the PHP it links to: <?php $filename = $_POST[filename]; $uploaddir = '/home/jjennings3/jjennings3.bimserver2.com/'; $uploadfile = $uploaddir . $filename; if (move_uploaded_file($_FILES['bookimage']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.<br>"; echo "Its name is <a href=$filename>$filename</a>"; } else { echo "There was an error."; } ?> any help would be greatly appreiciated Jonny
  15. okay, i have sorted some things out but i have a new error message: Notice: Unknown column 'xxx' in 'where clause' SELECT * FROM tblProperties WHERE xxx=xxx in /home/jjennings3/jjennings3.bimserver2.com/search.php on line 18 heres how the code looks at the moment: <?php $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet3475783'); mysql_select_db('jjennings3db', $conn); $sql = "SELECT * FROM tblProperties WHERE xxx=xxx"; echo "Here are all the properties that match your search:<br>"; if ($result1 = mysql_query($sql, $conn)) { if (mysql_num_rows($result1)) { while ($array1 = mysql_fetch_array($result1)) { echo "<p>Property Name: " . $array1['PropertyName'] . "<br>"; echo "Location: " . $array1['Location'] . "</p>"; } } else { echo "No results found"; } } else { trigger_error(mysql_error() . "<br />" . $sql); } ?>
  16. what do you mean by odd quotes? are they the wrong type or not the correct amount?
  17. I have inserted the new code and connected to the DB. I am getting a new error message: Notice: No database selected SELECT * FROM tblProperties WHERE xxx=xxx in /home/jjennings3/jjennings3.bimserver2.com/search.php on line 19 line 19 is : trigger_error(mysql_error() . "<br />" . $sql); I am confused 8-S thanks for the help
  18. I have created an array to store data extracted from a dedicated database. I cannot get the code to work and keep geeting an error on line 9; however i cannot see what the error is 8-S. Heres the code: <?php $conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet234345'); mysql_select_db(“jjennings3db”, $conn); $sql = "SELECT * FROM tblProperties WHERE xxx=xxx"; echo "Here are all the properties that match your search:<br>"; $result1 = mysql_query($sql, $conn); while ($array1 = mysql_fetch_array($result1)) { echo "<p>Property Name: " . $array1[PropertyName] . "<br>"; echo "Location: " . $array1[Location] . "</p>"; } ?> p.s I have changed log on details many thanks Jonny
  19. thankyou! the details have been changed from the original detials, ill give the code you posted a try.
  20. yes, the site has been specifically set up for the task. The errors i get are: Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host '“jjennings3dbbimserver2com”' (2) in /home/jjennings3/jjennings3.bimserver2.com/home-ltd.php on line 3 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/jjennings3/jjennings3.bimserver2.com/home-ltd.php on line 5 Properties Availible: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jjennings3/jjennings3.bimserver2.com/home-ltd.php on line 11 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jjennings3/jjennings3.bimserver2.com/home-ltd.php on line 13
  21. Hello! i am creating a page that connects to an online database that I have set up. I cannot seem to connect however and as i am new to this the problem is not obvious to me... Heres the code i have used: <?php $conn = mysql_connect(“jjennings3db.bimserver2.com”, “jjennings3db”, “bullet1238”); mysql_select_db("jjennings3db", $conn); $sql = "SELECT * FROM tblProperties"; echo "Properties Availible:<br>"; $result = mysql_query($sql, $conn); while ($array = mysql_fetch_array($result)) { echo "<p>Property Name: " . $array[PropertyName] . "<br>"; "</p>"; } ?> Thankyou for any assistance you are able to give. Jonny
  22. That would be great =]. its difficult trying to get my head around 8-S. thank you for all your help
  23. Hi, I am new to coding in PHP and i am in the process of creating a page that lets a user choose from rock, paper or scissors. The form page links to another page which chooses a random number from 1-3. 1=rock, 2=paper and 3=scissors. A series of IF statements are used to see who has won; the user or the PC. I cant get this script to work and I cant see why. any comments will be gratefully received. The code for the form page: <html> <head> <title>Rock, Paper, Scissors</title> </head> <body> <h3>Rock Paper Scissors</h3> <p>Choose iether rock paper or scissors<P> <form action="result.php" method="post"> Rock <input type="checkbox" name ="rock " value="rock"/><br/> Paper <input type="checkbox" name ="paper" value="paper"/><br/> Scissors <input type="checkbox" name ="scissors" value="scissors"/><br/> <input type= "submit" value = "submit" /><br/> </form> </body> </html> The second page: <?php $computer=rand(1,3); //1=rock, 2=paper, 3=scissors if ($human==rock){ if ($computer==1){ echo"Draw"; } elseif ($computer==2){ echo"Paper beats Rock - You Lose"; } else { echo"Rock beats scissors - You Win!"; } if ($human==paper){ if ($computer==1){ echo"Paper beats Rock - You Win!"; } elseif ($computer==2){ echo"draw"; } else { echo"Scissors beats Paper = You Lose"; } if ($human==scissors){ if ($computer==1){ echo"rock beats scissors - You Lose"; } elseif ($computer==2){ echo"Scissors beats Paper - You Win!"; } else { echo"draw"; } ?> MANY THANKS
  24. the idea behind this document is that it can convert imperial to metric and vise versa. Ive used drop down lists to enable the user to switch between Kilogram, centimetres ect. The other allows it to be converted the other way, however only the first drop down list works. here's the HTML page <html> <head> <title>Imperial to Metric</title> </head> <body> <form method="post" action="converter.php"> <input name = "number1" type="text"> <select name = "operator"> <option value = "Kilometres">Kilometres</option> <option value = "Centimetres">Centimetres</option> <option value = "Kilograms">kilograms</option> <option value = "Kilowatts">Kilowatts</option> <option value = "Litres">Litres</option> </select> <p> <input name = "number2" type="text"> <select name = "operator"> <option value = "Mile">Mile</option> <option value = "Inch">Inch</option> <option value = "Pound">Pound</option> <option value = "Horsepower">Horsepower</option> <option value = "Pint">Pint</ption> <input name = "Submit" type = "submit" value="="> </form> </body> </html> and heres the PHP page it links to <?php $kilometres = "1.609"; $centimetres = "2.54"; $kilograms = "0.454"; $kilowatts = "0.746"; $litres = "0.568"; $number1 = $_POST[number1]; $operator = $_POST[operator]; $operator1 = $_POST[operator]; if ($operator=="Kilometres"){ $answer = "$number1 miles equals ".($number1 * 1.609)." kilometres" ; } elseif ($operator == "Centimetres"){ $answer = "$number1 inches equals ".($number1 * 2.54)." centimetres" ; } elseif ($operator == "Kilograms"){ $answer = "$number1 Pounds equals ".($number1 * 0.454)." Kilograms" ; } elseif ($operator == "Kilowatts"){ $answer = "$number1 horsepower equals ".($number1 * 0.746)." Killowatts" ; } else{ $answer = "$number1 pints equals ".($number1 * 0.568). " litres" ; } echo "$answer"; if ($operator1=="Mile"){ $answer2 = "number2 kilometres equals ".($number2 * 0.621)." Miles" ; } else if $operator1 == "Inches"){ $answer2 = "$number2 centimetres equals ".($number2 * 0.393)." Inches" ; } else if $operator1 == "Pound"){ $answer2 = "$number2 kilograms equals ".($number2 * 2.204)." Pound" ; } else if $operator1 == "Horsepower"){ $answer2 = "$number2 Kilowatts equals ".($number2 * 1.34)." Horsepower" ; else{ $answer2 litres equals ".($number * 1.76). " Pints ; } echo "$answer2"; ?> thanks John
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.