Jump to content

ericburnard

Members
  • Posts

    46
  • Joined

  • Last visited

Everything posted by ericburnard

  1. ok i have taken the exit bit ot from here if($_GET['page'] == $id){ header("Location: http://ericburnard.freehostia.com/{$link}"); exit; } It dosnt work when i go to the page but when i refresh the page it will load the right page. Any ideas anyone??
  2. Ok ive tried that. When p go to ?page=1 i get if(1==logoff){ header('location: http://ericburnard.freehostia.com/logoff.php'); } else { echo 'Sorry Page Not Found' } For every other page number i get sorry page not found. Ive deleted my cookies loged in again as admin (admin pages are 3 and 4), and when i go on pages 3 and 4 i still get "sorry page not found". At least there is no error this time
  3. I gave that a go but got unexpected $ as an error which is only the closing bracket of the php ?>
  4. Are you saying its not possible to do what im trying to do??
  5. Hi the. Its been a good few years since i last played around with coding anything, and i decided the other day to see what i could come up with again. But ive hit a problem. Could you tell me if the following code is allowed. Ive split the IF function up so that the elseif can be repeated as many times as it needs to. Here is the code: <? include ('db.php'); ob_start(); $cookie=$_COOKIE["d_login"]; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM deptabs WHERE dep='$cookie'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); if($_GET['page']==logoff){ header('location: http://ericburnard.freehostia.com/logoff.php'); } $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $tab=mysql_result($result,$i,"tab"); $link=mysql_result($result,$i,"link"); $dep=mysql_result($result,$i,"dep"); elseif ($_GET ==$id){ header('location: http://ericburnard.freehostia.com/$link'); } $i++; } else { echo "Sorry Page Not Found"; } ob_end_flush(); ?> And here is the error im getting: Parse error: parse error, unexpected T_ELSEIF in /home/www/ericburnard.freehostia.com/test.php on line 31 Pointers in the right direction would be awesome. Chears Eric x
  6. This is the form page <? include ('mheader.html'); include ('db.php'); echo ' <div id="f1"> <form action="upload2.php" method="post" enctype="multipart/form-data" class="f1"> <table border="0pt"> <tr> <td> <label for="file"> Filename: </label> </td> <td><input type="file" name="file" id="file" class="texta"/> </td> </tr> <tr> <td>Photo Name: </td> <td><input type="text" name="pname" class="texta"> </td> </tr> <tr> <td>Description: </td> <td><input type="text" name="des" class="texta"> </td> </tr> <tr> <td>Whos In It: </td> <td><input type="text" name="who" class="texta"> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Submit" class="texta"> </td> </tr> </table> </form> </div>'; include ('footer.html'); ?>
  7. This is the error i get - Notice: Undefined index: file in /home/www/ericburnard.freehostia.com/upload2.php on line 7 Notice: Undefined index: file in /home/www/ericburnard.freehostia.com/upload2.php on line 8 Notice: Undefined index: file in /home/www/ericburnard.freehostia.com/upload2.php on line 9 the script on those lines is - 7 if (($_FILES["file"]["type"] == "image/gif") 8 || ($_FILES["file"]["type"] == "image/jpeg") 9 || ($_FILES["file"]["type"] == "image/pjpeg") 10 && ($_FILES["file"]["size"] < 1000000))
  8. Ive just written my first upload script. When i upload a picture it should be placed in the folder "images/uploads" When the script is run it says the image was uploaded and the data is in the database but when i look in the folder the image is not there. this is my code <?php include ('mheader.html'); include ('db.php'); if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg") && ($_FILES["file"]["size"] < 1000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; $file = $_FILES["file"]["name"]; if (file_exists("images/uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "images/uploads/" . $_FILES["file"]["name"]); echo "Stored in images/uploads/ <BR><BR><BR>"; $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("erikee10_eric", $con);$sql="INSERT INTO photos (file, pname, des, who, date) VALUES ('$file','$_POST[pname]','$_POST[des]','$_POST[who]','$_POST[date]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } } } else { echo "Invalid file"; } ?> sorry if its a bit messy :s Eric
  9. Thanks for that ken, the only problem is that im not getting anything diplayed im getting my header and if i echo some text i get that but its not displaying anything in the database?? Im not amazing at php so could you explain some of the changes for me Thanks Eric
  10. Hi there i have the following javascript <table width=150><tr><td> <script language="JavaScript"> //Link[nr] = "position [0 is menu/1 is item],Link name,url,target (blank|top|frame_name)" var Link = new Array(); Link[0] = "0|Home"; Link[1] = "1|Home|http://www.javascriptsource.com|"; Link[2] = "1|More Scripts|http://www.javascript.com|"; Link[3] = "1|Contact|http://www.javascriptsource.com/contact-us.html|"; Link[4] = "1|Traffic|http://www.thecounter.com|"; Link[5] = "0|Access"; Link[6] = "1|Login|Login.asp|"; Link[7] = "1|Logout|Logout.asp|" Link[8] = "0|Scripts"; Link[9] = "1|Asp|http://www.javascriptsource.com|"; Link[10] = "1|JavaScript|http://www.javascriptsource.com|"; Link[11] = "0|Links"; Link[12] = "1|JavaScript sites|http://www.javascripts.com|blank"; startup(4); </script> </td></tr></table> As you can see the link number increases every time. I have put what i need of this code into my php - <? include('mheader.html'); include ('db.php'); $cookie=$_COOKIE["cusername"]; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM blog ORDER BY id DESC"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<table width=150><tr><td> <script language='JavaScript'> //Link[nr] = 'position [0 is menu/1 is item],Link name,url,target (blank|top|frame_name)' var Link = new Array();"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $subject=mysql_result($result,$i,"subject"); $blog=mysql_result($result,$i,"blog"); $date=mysql_result($result,$i,"date"); echo " Link[0] = '0|$id : $subject : $date'; Link[1] = '1|$blog|$blog|';"; $i++; }; echo "startup(4); </script> </td></tr></table><BR><BR>"; ?> The only problem i have now is that when the script repeats itself its just using the numbers 0 and 1 what i need it to do is 0,1 then the next repeat 2,3 the next 4,5 and so on im not to sure how to go about doing this?? Any help would be great. Thanks again Eric
  11. Hey i have read the header stick looked it up on numerous websites but i am still confussed about why i get this error Warning: Cannot modify header information - headers already sent by (output started at /home/www/ericburnard.freehostia.com/index2.php:1) in /home/www/ericburnard.freehostia.com/header.html on line 2 Warning: Cannot modify header information - headers already sent by (output started at /home/www/ericburnard.freehostia.com/index2.php:1) in /home/www/ericburnard.freehostia.com/header.html on line 3 Warning: Cannot modify header information - headers already sent by (output started at /home/www/ericburnard.freehostia.com/index2.php:1) in /home/www/ericburnard.freehostia.com/header.html on line 4 This is the code i am using. <?php // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title>.: Eric's Blog :.</title> <? $p = $_GET['p']; if ($p == 'home') { echo "This is the home file"; } else if ($p == 'login') { header('Location:www.login.com'); } else if ($p == 'photos') { echo "This is the photos file"; } else if ($p == 'wall') { echo "This is the wall file"; } else if ($p == 'links') { echo "This is the links file"; } else if ($p == 'contact') { echo "This is the contact file"; } else { echo "No page with that ID exists."; } ?> </head> <body> <div style="position: Absolute; left: 140px; top: 70px; height: 10px; width: 10px; padding: 1em; z-index: 1"> <form name="input" action="login.php" method="get"> Username: <input type="text" name="username" class="text"width="20"><BR> Password: <input type="password" name="password" class="text" width="20"><br><br> <input type="submit" value="Submit" class="submit"> </form> </div> <div id="container"> <div id="header"> <ul> <li><a href="?p=home">Home</a></li> <li><a href="?p=login">Login</a></li> <li><a href="?p=photos">Photos</a></li> <li><a href="?p=wall">Wall</a></li> <li><a href="?p=links">Links</a></li> <li><a href="?p=contact">Contact</a></li> </ul> </div> <br><br> <div id="footer"></div> Any help would be great Eric x
  12. No the database name is exactly the same. Im stumpped Help Please!!!
  13. Sorry about that. im new and didnt realise about the topic names. The one i am trying now is on this site - http://www.phpfreaks.com/tutorials/142/6.php I took the last bit out because the "Forment" bit wasnt working so i now have this - <?php // database information $host = '********'; $user = '*********'; $password = '*********'; $dbName = '********'; // connect and select the database $conn = mysql_connect($host, $user, $password) or die(mysql_error()); $db = mysql_select_db($dbName, $conn) or die(mysql_error()); // insert new entry in the database if entry submitted if (isset($_POST['newEntry']) && trim($_POST['newEntry']) != '') { // for easier variable handling... $newEntry = $_POST['newEntry']; // insert new entry into database $sql = "insert into testTable (someField) values ('$newEntry')"; $result = mysql_query($sql, $conn) or die(mysql_error()); } // end if new entry posted // select all the entries from the table $sql = "select someField from testTable"; $result = mysql_query($sql, $conn) or die(mysql_error()); // echo out the results to the screen while ($list = mysql_fetch_array($result)) { echo "{$list['someField']} <br>"; } // end while ?> All i am getting is this error The username and password are correct, and i dont no what else to think of. Its bound to be really really simple but nevermind. Any help would be much loved Cheers Eric xxxxxxxx
  14. Right ive written my own code used other people taken bits out of programs all i can think off but i cant connect to my database. The host address, username, and password are all correct its just it cannot connect to the database. all the letters are in lower case there is something in the database for it to display. Its getting right up my nose now!!! Any help would be amazing Thanks Eric x
  15. I had to change it to this because ther were some errors - if (!$link) die('Could not connect: ' . mysql_error()); echo 'Connected successfully'; but still get this http://ericburnard.freehostia.com/db.php
  16. I had to change it to this because ther were some errors - if (!$link) die('Could not connect: ' . mysql_error()); echo 'Connected successfully'; but still get this http://ericburnard.freehostia.com/db.php
  17. Hey i havnt used php or any language for a good few years now, ive decided to get back into it again. Ive set up a sql database and tried to work out the php code to get the entries out of the table (code below) but im just getting these messages - http://ericburnard.freehostia.com/db.php <?php $link = mysql_connect('mysql2.freehostia.com', '*******', '*********'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $link or die ("Problem connecting to DataBase"); $query = "SELECT * FROM `Blog`"; $result = mysql_select_db($query); if ($result) { echo "Found these entries in the database:<br><p></p>"; while ($r = mysql_fetch_array($result)) { $date = $r["date"]; $subject = $r["subject"]; $blog = $r["blog"]; $id = $r["id"]; echo "<tr> <td>$id</td> <td>$date</td> <td>$subject</td> <td>$blog</td> </tr>"; } echo "</table>"; } else { echo "No data."; } ?> What am i doing wrong??? Cheers xxxxx
×
×
  • 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.