Jump to content

el_nino

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by el_nino

  1. problem solved, forgot to get the id in the previous script
  2. ok that makes sense and solved that issue. i have one more issue and then i'll be gone, i promise lol Once the record has been updated, i have a link which will allow the user to view the updated record. I am using the same method as the one used when allowing the user to select a profile to edit but this time the selected record will be displayed in a table rather than a form. I'm having the same problem that i initially had in that the record is not being displayed. No error messages are being returned, only the headings of the table are. updated.php <html> <head> <title>Updated Profile</title> </head> <div align="center"> <?php include ('includes/header.html') ?> <?php //connect to your database mysql_connect("","","") or die("cannot connect"); //(host, username, password) //specify database mysql_select_db("") or die("Unable to select database"); //select which database we're using); ?> <?php //$id=$_GET['id']; $id = (is_numeric($_GET['id'])) ? $_GET['id'] : 0; //$PlayerID = ((isset($_GET['PlayerID'])) ? $_GET['PlayerID'] : 0); $query = "select * from players WHERE PlayerID ='$id'"; $result = mysql_query($query) or die("Couldn't execute query. MySQL Said: ".mysql_error()); $row = mysql_fetch_assoc($result); //$numresults=mysql_query($query); //$numrows=mysql_num_rows($numresults); ?> <?php $result = mysql_query($query) or die("Couldn't execute query. MySQL Said: ".mysql_error()); echo "<p> &nbsp </p>"; echo "<h1>Updated Record</h1></br>"; echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>DOB</th> <th>Club</th> <th>Number</th> <th>Cost</th> <th>Position</th> <th>National Team</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['Name']; echo "</td><td>"; echo $row['DOB']; echo "</td><td>"; echo $row['Club']; echo "</td><td>"; echo $row['Number']; echo "</td><td>"; echo $row['Cost']; echo "</td><td>"; echo $row['Position']; echo "</td><td>"; echo $row['NationalTeam']; echo "</td></tr>"; } echo "</table>"; echo "<p>&nbsp </p>"; ?> <p>&nbsp </p> <p><a href="loggedin.php"> Take me back to my member page </a></p> <p>&nbsp </p> <p><a href="logout.php"> Log me out, i'm done </a></br></p> </br> <?php echo "<p>&nbsp </p>"; include ('includes\footer.html'); ?> <div align="center"> </html> thanks in advance
  3. so i have update_v2.php which will allow me view the selected record in a form so that the user can edit it. update_v2.php <html> <head> <title>Edit</title> </head> <div align="center"> <?php include ('includes/header.html') ?> <?php //connect to your database mysql_connect("","","") or die("cannot connect"); //(host, username, password) //specify database mysql_select_db("") or die("Unable to select database"); //select which database we're using); ?> <?php //$id=$_GET['id']; $id = (is_numeric($_GET['id'])) ? $_GET['id'] : 0; //$PlayerID = ((isset($_GET['PlayerID'])) ? $_GET['PlayerID'] : 0); //$query = "select * from players WHERE PlayerID ='$id'"; //echo $query; $query = "select * from players WHERE PlayerID ='$id'"; $result = mysql_query($query) or die("Couldn't execute query. MySQL Said: ".mysql_error()); $row = mysql_fetch_assoc($result); //echo $query; //$numresults=mysql_query($query); //$numrows=mysql_num_rows($numresults); ?> <body> <h1>Edit Record</h1> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <form name="form1" method="post" action="update_ac.php"> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>DOB</strong></td> <td align="center"><strong>Club</strong></td> <td align="center"><strong>Number</strong></td> <td align="center"><strong>Cost</strong></td> <td align="center"><strong>Position</strong></td> <td align="center"><strong>National Team</strong></td> </tr> <tr> <td> </td> <td align="center"><input name="Name" type="text" size="15" value="<?php echo $row['Name']; ?>"></td> <td align="center"><input name="DOB" type="date" size="10" value="<?php echo $row['DOB']; ?>"></td> <td align="center"><input name="Club" type="varchar" size="15" value="<?php echo $row['Club']; ?>"></td> <td align="center"><input name="Number" type="int" size="2" value="<?php echo $row['Number']; ?>"></td> <td align="center"><input name="Cost" type="text" size="15" value="<?php echo $row['Cost']; ?>"></td> <td align="center"><input name="Position" type="text" size="15" value="<?php echo $row['Position']; ?>"></td> <td align="center"><input name="NationalTeam" type="text" size="15" value="<?php echo $row['NationalTeam']; ?>"></td> </tr> <tr><td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td><input name="id" type="hidden" id="id" value="<?php echo $row['PlayerID']; ?>"></td> <td align="center"><input type="submit" name="Submit" value="Update"></td> <td> </td> </tr> </table> </td> </form> </tr> </table> <p>&nbsp </p> <p><a href="loggedin.php"> Take me back to my member page </a></p> <p>&nbsp </p> <p><a href="logout.php"> Log me out, i'm done </a></br></p> </br> </body> <? // close connection mysql_close(); ?> <?php echo "<p>&nbsp </p>"; include ('includes\footer.html'); ?> <div align="center"> </html> and the script update_ac.php which is supposed to update the record in the database. update_ac.php <html> <head> <title>Edit</title> </head> <div align="center"> <?php include ('includes/header.html') ?> <?php $Name = trim($_POST['Name']); $DOB = trim($_POST['DOB']); $Club = trim($_POST['Club']); $Number = trim($_POST['Number']); $Cost = trim($_POST['Cost']); $Position = trim($_POST['Position']); $NationalTeam = trim($_POST['NationalTeam']); //connect to your database mysql_connect("","","") or die("cannot connect"); //(host, username, password) //specify database mysql_select_db("") or die("Unable to select database"); //select which database we're using); // update data in mysql database $sql="UPDATE players SET Name='$Name', DOB='$DOB', Club='$Club', Number='$Number', Cost='$Cost', Position='$Position', NationalTeam='$NationalTeam' WHERE PlayerID='$id'"; $result = mysql_query($sql) or die("Couldn't execute query. MySQL Said: ".mysql_error()); echo " "; echo $query; echo " "; $result=mysql_query($sql); // if successfully updated. if($result){ echo "<h1>Record Successfully Updated</h1>"; echo "<BR>"; echo "<h3><a href='show_all.php'>View Updated Record</h3></p>"; echo " "; echo "<p><a href='loggedin.php'> Take me back to my member page</a></p>"; echo " "; echo "<p><a href='list_records_profiles.php'> I want to edit more profiles</a></p>"; echo " "; echo "<p><a href='logout.php'> Log me out, i'm done</a></p>"; } else { echo "<h1>ERROR</h1>"; echo "<a href='list_records_profiles.php'>Click here to go back and try again</a>"; echo "<a href='loggedin.php'> Take me back to my member page </a>"; } ?> <?php echo "<p>&nbsp </p>"; include ('includes\footer.html'); ?> <div align="center"> </html> the message output by the script above seems to indicate that the record has been successfully updated but this does not seem to be the case
  4. thank you just need to get the record to update now, i'll let you know how that goes. getting an error message at the moment
  5. ok, i've kinda solved the problem in that i am able to output the selected record into a table so the user can view it, but when i attempt to output it into a form so it can be edited i just end up with a blank form. the script i created to output the selected record into a form is: update_v2.php <html> <head> <title>Edit</title> </head> <div align="center"> <?php include ('includes/header.html') ?> <?php //connect to your database mysql_connect("","","") or die("cannot connect"); //(host, username, password) //specify database mysql_select_db("") or die("Unable to select database"); //select which database we're using); ?> <?php //$id=$_GET['id']; $id = (is_numeric($_GET['id'])) ? $_GET['id'] : 0; //$PlayerID = ((isset($_GET['PlayerID'])) ? $_GET['PlayerID'] : 0); $query = "select * from players WHERE PlayerID ='$id'"; echo $query; //$numresults=mysql_query($query); //$numrows=mysql_num_rows($numresults); ?> <body> <h1>Edit Record</h1> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <form name="form1" method="post" action="update_ac.php"> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>DOB</strong></td> <td align="center"><strong>Club</strong></td> <td align="center"><strong>Number</strong></td> <td align="center"><strong>Cost</strong></td> <td align="center"><strong>Position</strong></td> <td align="center"><strong>National Team</strong></td> </tr> <tr> <td> </td> <td align="center"><input name="Name" type="text" size="15" value="<?php echo $row['Name']; ?>"></td> <td align="center"><input name="DOB" type="date" size="20" value="<?php echo $row['DOB']; ?>"></td> <td align="center"><input name="Club" type="varchar" size="15" value="<?php echo $row['Club']; ?>"></td> <td align="center"><input name="Number" type="int" size="15" value="<?php echo $row['Number']; ?>"></td> <td align="center"><input name="Cost" type="text" size="15" value="<?php echo $row['Cost']; ?>"></td> <td align="center"><input name="Position" type="text" size="15" value="<?php echo $row['Position']; ?>"></td> <td align="center"><input name="NationalTeam" type="text" size="15" value="<?php echo $row['NationalTeam']; ?>"></td> </tr> <tr><td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td><input name="id" type="hidden" id="id" value="<?php echo $row['PlayerID']; ?>"></td> <td align="center"><input type="submit" name="Submit" value="Update"></td> <td> </td> </tr> </table> </td> </form> </tr> </table> </body> <? // close connection mysql_close(); ?> <?php echo "<p>&nbsp </p>"; include ('includes\footer.html'); ?> <div align="center"> </html> help?
  6. when i echo the query it seems to show that the value for PlayerID does not seem to be making it
  7. Zanus - I made the change you suggested and now I can see the ID in the url when i place the cursor over the update link but the selected record is still not being displayed on the following page where the user could change the values
  8. Hi I have created a script which should let me edit selected records in the database. the scripts i have created are: list_records_prfiles.php update.php update_ac.php what seems to be the problem is that the code <a href="update.php?id=<? echo $row['PlayerID']; ?>">update</a> does not seem to be working. When i hover over the update link on the webpage the ['PlayerID'] does not seem to be replaced with the actual ID. this means that when the user clicks on the update link no records are displayed, only the headings of the table are displayed. list_records_prfiles.php <html> <head> <title>All Profiles</title> </head> <div align="center"> <?php include ('includes/header.html') ?> <body> <?php //Connect to Database //connect to your database mysql_connect("****","****","****"); //(host, username, password) //specify database mysql_select_db("****") or die("Unable to select database"); //select which database we're using ?> <?php // Build SQL Query $query = "select * from players order by Club"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); $result = mysql_query($query) or die("Couldn't execute query. MySQL Said: ".mysql_error()); echo "<p> &nbsp </p>"; echo "<h1>All Profiles</h1></br>"; echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>DOB</th> <th>Club</th> <th>Number</th> <th>Cost</th> <th>Position</th> <th>National Team</th> <th>Edit</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['Name']; echo "</td><td>"; echo $row['DOB']; echo "</td><td>"; echo $row['Club']; echo "</td><td>"; echo $row['Number']; echo "</td><td>"; echo $row['Cost']; echo "</td><td>"; echo $row['Position']; echo "</td><td>"; echo $row['NationalTeam']; echo "</td><td>"; ?> <a href="update.php?id=<? echo $row['PlayerID']; ?>">update</a> <?php echo "</td></tr>"; } echo "</table>"; echo "<p>&nbsp </p>"; ?> </body> <div align="center"> <?php include ('includes\footer.html'); ?> </html> update.php <?php //connect to your database mysql_connect("****","****","****"); //(host, username, password) //specify database mysql_select_db("****") or die("Unable to select database"); //select which database we're using); $PlayerID=$_GET['PlayerID']; $query = "select * from players WHERE PlayerID ='$PlayerID'"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); ?> <?php $result = mysql_query($query) or die("Couldn't execute query. MySQL Said: ".mysql_error()); echo "<p> &nbsp </p>"; echo "<h1>All Profiles</h1></br>"; echo "<table border='1'>"; echo "<form name='form1' method='post' action='update_ac.php'>"; echo "<tr> <th>Name</th> <th>DOB</th> <th>Club</th> <th>Number</th> <th>Cost</th> <th>Position</th> <th>National Team</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['Name']; echo "</td><td>"; echo $row['DOB']; echo "</td><td>"; echo $row['Club']; echo "</td><td>"; echo $row['Number']; echo "</td><td>"; echo $row['Cost']; echo "</td><td>"; echo $row['Position']; echo "</td><td>"; echo $row['NationalTeam']; echo "</td></tr>"; } echo "</table>"; echo "<p>&nbsp </p>"; ?> <table> <tr> <td> </td> <td><input name="PlayerID" type="hidden" id="PlayerID" value="<? echo $row['PlayerID']; ?>"></td> <td align="center"><input type="submit" name="Submit" value="Submit"></td> <td> </td> </tr> </table> </td> <?php echo "</form>"; ?> </tr> </table> update_ac.php <?php //connect to your database mysql_connect("****","****","****"); //(host, username, password) //specify database mysql_select_db("****") or die("Unable to select database"); //select which database we're using); // update data in mysql database $sql="UPDATE players SET name='$Name', dob='$DOB', club='$Club' number='$Number', cost='$Cost' position='$Position', nationalteam='$NationalTeam' WHERE id='$PlayerID'"; $result=mysql_query($sql); // if successfully updated. if($result){ echo "Successful"; echo "<BR>"; echo "<a href='list_records_profiles.php'>View result</a>"; } else { echo "ERROR"; } ?> help? thanks el nino
  9. the reason i didnt add the other variables is because i just wanted to ensure that the query worked for that one radio button, is that possible or do i need to include all the other posted variables in the query even if the user was user was only to select one of the options?
  10. ok, so the code i have come up with looks like: <?php ini_set('display_errors', '1'); error_reporting(E_ALL); ?> <html> <head> <title>Advanced Search</title> </head> <div align="center"> <body> <p> </p> <?php include ('includes\header.html'); ?> <?php // Get the search variable from URL $var = @$_POST['asearch']; ?> <?php //connect to your database mysql_connect("****","****","****"); //(host, username, password) //specify database mysql_select_db("****") or die("Unable to select database"); //select which database we're using $the_query = "SELECT * FROM players WHERE Number like '".$_POST['clubno']."'"; if (!empty($_POST['asearch'])) { $the_query = $the_query . "active_player = " . $_POST['asearch']; } if (!empty($_POST['clubno'])) { $the_query = $the_query . " clubno = " . $_POST['clubno']; } if (!empty($_POST['playing'])) { $the_query = $the_query . " playing = " . $_POST['playing']; } if (!empty($_POST['nationality'])) { $the_query = $the_query . " nationality = " . $_POST['nationality']; } if (!empty($_POST['position'])) { $the_query = $the_query . " position = " . $_POST['position']; } $numresults=mysql_query($the_query); //$numrows=mysql_num_rows($numresults); // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results //$the_query .= " limit $s,$limit"; echo "<p> </p>"; $result = mysql_query($the_query) or die("Couldn't execute query"); // begin to show results set echo "Results"; $count = 1 + $s; echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>DOB</th> <th>Club</th> <th>Number</th> <th>Cost</th> <th>Position</th> <th>National Team</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['Name']; echo "</td><td>"; echo $row['DOB']; echo "</td><td>"; echo $row['Club']; echo "</td><td>"; echo $row['Number']; echo "</td><td>"; echo $row['Cost']; echo "</td><td>"; echo $row['Position']; echo "</td><td>"; echo $row['NationalTeam']; echo "</td></tr>"; } echo "</table>"; ?> </body> <div align="center"> <?php include ('includes\footer.html'); ?> </html> but i now get the error "Couldn't execute query"
  11. ok, this is what i have so far <html> <div align="center"> <body> <p>&nbsp</p> <?php include ('includes\header.html'); ?> <?php // Get the search variable from URL $var = @$_POST['asearch'] ; ?> <?php //connect to your database mysql_connect("*****","*****","*****"); //(host, username, password) //specify database mysql_select_db("*****") or die("Unable to select database"); //select which database we're using $the_query = "SELECT * FROM players WHERE Number like /%clubno%/ if (!empty($_POST['asearch']) { $the_query = $the_query . "active_player = " . $_POST['asearch']; } if (!empty($_POST['clubno']) { $the_query = $the_query . " clubno = " . $_POST['clubno']; } if (!empty($_POST['playing']) { $the_query = $the_query . " playing = " . $_POST['playing']; } if (!empty($_POST['nationality']) { $the_query = $the_query . " nationality = " . $_POST['nationality']; } if (!empty($_POST['position']) { $the_query = $the_query . " position = " . $_POST['position']; } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // begin to show results set echo "Results"; $count = 1 + $s ; echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>DOB</th> <th>Club</th> <th>Number</th> <th>Cost</th> <th>Position</th> <th>National Team</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['Name']; echo "</td><td>"; echo $row['DOB']; echo "</td><td>"; echo $row['Club']; echo "</td><td>"; echo $row['Number']; echo "</td><td>"; echo $row['Cost']; echo "</td><td>"; echo $row['Position']; echo "</td><td>"; echo $row['NationalTeam']; echo "</td></tr>"; } echo "</table>"; ?> </body> <div align="center"> ?> <?php include ('includes\footer.html'); ?> </html> but i'm kinda lost now :-\ with the actual query
  12. that line was supposed to be... { $the_query = $the_query . "active_player = " . $_POST['asearch']; }
  13. cheers... ok so i've got all the variable that could be sent and i think i know what comes next but before i attempt the next part could you explain the following line: { $the_query = $the_query . "active_player = " . $_POST['asearch']; } [code=php:0] thanks
  14. I have implemented a search function on to my website which works as expected when the user enters a value in the search engine. I am now wanting to add an advanced search feature which will allow the user to narrow down their search by selecting values using radio buttons, check boxes and a drop down list. I have created the form, this can be seen below: <html> <head> <title>Advanced Search</title> </head> <div align="center"> <?php include ('includes/header.html') ?> <body> <p> &nbsp </p> <h1>Advanced Search</h1></br> <p>Narrow your search using the following options</p> <p> &nbsp </p> <form action="asearch.php" method="post"> <input type="text" name="asearch" /> <table table border='1' table width = 50%> <tr><th COLSPAN=4>Is this player still playing?</th></tr> <tr><td> <p> &nbsp </p> </td><td> <input type="radio" name="playing" value="Retired" /> Retired </td><td> <input type="radio" name="playing" value="Still Playing" /> Still Playing </td><td> <p> &nbsp </p> </td></tr> <tr><th COLSPAN=4>What Nationality is the player?</th></tr> <tr><td> <p> &nbsp </p> </td><td> <select name="nationality" align="center"> <option value="all">Any</option> <option value="african">African</option> <option value="aisian">Asian</option> <option value="european">European</option> <option value="namerican">North American</option> <option value="samerican">South American</option> <option value="oceanian">Oceanian</option> <option value="uncapped">*Uncapped</option> </select> </td><td> (select "any" if unsure) </td><td> <p> &nbsp </p> </td></tr> <tr><th COLSPAN=4>Position?</th></tr> <tr><td> Goalkeeper <input type="checkbox" name="position" value="goalkeeper" /> </td><td> Defener <input type="checkbox" name="position" value="defender" /> </td><td> Midfielder <input type="checkbox" name="position" value="midfielder" /> </td><td> Striker <input type="checkbox" name="position" value="striker" /> </td></tr> <tr><th COLSPAN=4>Club Shirt Number</th></tr> <tr><td> <input type="radio" name="clubno" value="0111" /> #1 - #11 </td><td> <input type="radio" name="clubno" value="1230" /> #12 - #30 </td><td> <input type="radio" name="clubno" value="3159" /> #31- #59 </td><td> <input type="radio" name="clubno" value="6099" /> #60 - #99 </td></tr> </table> <p> &nbsp </p> <input type="submit" name="submit" value="Search" /> <input type="hidden" name="submitted" value="TRUE" /> <p> &nbsp </p> <p>* select Uncapped in the player has not yet been called up by the national team</p> <p> &nbsp </p> </form> <p> &nbsp </p> </body> <?php include ('includes/footer.html') ?> </div> </html> would anyone be able to get me started on the query i would use in the file asearch.php? thank you el nino
  15. ok, i don't quite understand what you mean... could you please elaborate/ give me an example
  16. i now get: SELECT * FROM `members` WHERE `Name` ='Guest' LIMIT ,;Could not execute query 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 '' at line 1 this looks like its correct in that the user that has just logged in is Guest and it is this users details that should be displayed i cant seem to see what is wrong at line 1
  17. right, so after doing that i now get the following error: Could not execute query: 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 '' at line 1 and also get: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\view_profile.php:3) in C:\xampp\htdocs\view_profile.php on line 4
  18. Hey... what I am trying to do is use the information stored in a session to display all the information of the user who has just logged in my script currently looks like... <?php session_start(); // Start the session. // If no session value is present, redirect the user: // Also validate the HTTP_USER_AGENT! if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) )) { require_once ('login_functions.inc.php'); $url = absolute_url(); header("Location: $url"); exit(); } ?> <html> <head> <title> My Profile</title> </head> <?php include ('includes\header.html'); ?> <?php //require_once ('mysql_connect.php'); //connect to your database mysql_connect("****","****","****"); //(host, username, password) //specify database mysql_select_db("****") or die("Unable to select database"); //select which database we're using ?> <body> <div align="center"> </br> <?php // Print a customized message: echo "<p>You are logged in as <b>{$_SESSION['Name']}!</b></p>"; ?> <?php //$query = "select * from members where Name = ['Name']"; //$query = "select * from members where Name = '$_SESSION['Name']'"; $query = "select * from members where Name = '" . $_SESSION['Name'] . "'"; //$numresults=mysql_query($query); //$numrows=mysql_num_rows($numresults); // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Could not execute query"); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Username</th> <th>DOB</th> <th>Team</th> <th>Email</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['Name']; echo "</td><td>"; echo $row['Username']; echo "</td><td>"; echo $row['DOB']; echo "</td><td>"; echo $row['Team']; echo "</td><td>"; echo $row['Email']; echo "</td></tr>"; } echo "</table>"; ?> </br> </div> </body> <?php include ('\includes\footer.html'); ?> </html> the error i am getting is "Could not execute query" el nino
  19. hey... I have a search function which is used to search my PostgreSQL database. I have included the code below <html> <head> <title>Search</title> </head> <div align="center"> <?php include ('includes/header.html') ?> <body> <p>&nbsp </p> <p>Enter a Author or Article title to begin searching</p> <p>&nbsp </p> <form name="form" action="search.php" method="post"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Search" /> </form> <p></p> <p>&nbsp </p> </body> <?php //include ('includes/footer.html') ?> </div> </html> and... <html> <head> <title>Search</title> </head> <?php include ('includes/header.html'); ?> <div align="center"> <body> <p>&nbsp</p> <?php //connecting to the database include('includes/db_connect.php') ?> <?php //$sql = "select * from jfs where author ilike '%$search_author%' order by issue"; //$sql = "select* from jfs where author like '%searchstring%' order by issue"; $sql = "select * from jfs where author ilike '%$search_author%'" ; $result_set = pg_Exec ($conn, $sql); $rows = pg_NumRows($result_set); if ((!$result_set) || ($rows < 1)) { echo "<H1>ERROR - no rows returned</H1><P>"; exit; //exit the script } for ($j=0; $j < $rows; $j++) { $issue = pg_result($result_set, $j, "issue"); $page = pg_result($result_set, $j, "page"); $author = pg_result($result_set, $j, "author"); $title = pg_result($result_set, $j, "title"); $format = pg_result($result_set, $j, "format"); $url = pg_result($result_set, $j, "url"); ?> <table table border="3" width=60%> <tr><th>Issue</th><th>Page</th><th>Author</th><th>Title</th><th>Format</th><th>URL</th></tr> <TR> <TD width=10%> <?php echo "<a href=$url> $issue </a>"; ?> </TD> <TD width=10%> <?php echo "<a href=$url> $page </a>"; ?> </TD> <TD width=15%> <?php echo "<a href=$url> $author </a>"; ?> </TD> <TD> <?php echo "<a href=$url> $title </a>"; ?> </TD> <TD width=10%> <?php echo "<a href=$url> $format </a>"; ?> </TD> <TD width=30%> <?php echo "<a href=$url> $url </a>"; ?> </TD> </TR> </table> <?php } ?> <?php pg_FreeResult($result_set); pg_Close($conn); ?> </TABLE> </body> </div> <?php //include ('includes\footer.html'); ?> </html> this works in that i get a set of results when the user enters a search term and click search and do not get results when no term is entered but the problem is that no matter what term is entered into the search field the same results show up every time. help? el nino
  20. problem solved... seemed to be issues with the servers at uni
  21. it must do because if i enter the url into my address bar i can see the page
  22. thanks for that...ok so i now get the following error Warning: file_get_contents(http://www.comp.brad.ac.uk/intranet/modules/DWT/jfs/formats.html) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in *file location* on line 54 line 54 is: echo file_get_contents($url);
×
×
  • 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.