Jump to content

yobo

Members
  • Posts

    87
  • Joined

  • Last visited

Everything posted by yobo

  1. yobo

    Mysql Join Issue

    Thanks Barand, But I am still getting errors; mysql> select postname, name from posts p join lookup l on p.id = l.postid join postcategory c on l.categoryid = c.id; ERROR 1146 (42S02): Table 'p3-blog.lookup' doesn't exist mysql> select postname, name from posts p join category l on p.id = l.postid jo in postcategory c on l.categoryid = c.id; ERROR 1054 (42S22): Unknown column 'l.postid' in 'on clause' mysql> select postname, name from posts p join postcategory l on p.id = l.posti d join postcategory c on l.categoryid = c.id; ERROR 1054 (42S22): Unknown column 'name' in 'field list' mysql> select postname from posts p join postcategory l on p.id = l.postid join postcategory c on l.categoryid = c.id; I have replaced the names with my tables: my lookup table is called 'postcategory' my category table is called 'category' and my posts table is called 'posts'
  2. yobo

    Mysql Join Issue

    Thanks Barand for your help however I am still getting errors, from folling your guidance, my lookup table is called 'postcategory' my category table is called 'category' and my posts table is called 'posts' using your sQL above mysql> select postname, name from posts p join lookup 1 on p.id = 1.postid join postcategory c on 1.categoryid = c.id; I get a Mysql error.
  3. Hello All, I am working on a small PHP / Mysql project and I have ran aground on this issue, and I am looking for some advice as to why this is not working. What I am trying to acheive is to show a list of blog post titles, along with their respective categories that they are assigned too, However I am unable to get my query to work. below are my 3 tables structure: The Posts table +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | postname | varchar(255) | NO | | NULL | | | postcontent | varchar(255) | NO | | NULL | | | postdate | date | NO | | NULL | | | authorid | int(11) | NO | | NULL | | +-------------+--------------+------+-----+---------+----------------+ The Category Table +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(255) | NO | | NULL | | +-------+--------------+------+-----+---------+----------------+ The Lookup table +------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------+------+-----+---------+-------+ | postid | int(11) | NO | PRI | 0 | | | categoryid | int(11) | NO | PRI | 0 | | +------------+---------+------+-----+---------+-------+ My query mysql> select id, postname from posts join postcategory on posts.id = categoryid; Empty set (0.00 sec) so far example it should look like this on the web page Post Name Post Category Linux DNS How Too Linux Windows 10 Hacks Windoiws Again grateful for any help. Joe
  4. Hey All, I am having some issues my data gets added to the database ok but since I am using a header redirection (to clear the $_post variable) my success message is not displayed or my error if there is an error. Basically I would like my message to be displayed just above the form to say success it worked or error if it did not. header("Location: addproduct.php"); echo ' <div class="span9" id="content"> <div class="alert alert-success"> <div id="success"><p>Product has been added to the database</p></div> </div> </div>'; exit; the above code is a snippet of my main code I am also using ajax to help with this. my simple ajax code $('#btnSave').click(function() { $.post($("#addproduct").attr("action"), data, function(info){ $("#success").html(info); }); clearInput()); }); $("#addproduct").submit( function() { return false; }); function clearInput() { $("#addproduct :input").each( function() { $(this).val(''); }); } Many Thanks J
  5. Hey All, I am in the process of learning PHP so I am not an expert by any means. I am looking for some advice on how I would go about implementing this idea. 1. I have a page called addproduct.php with a form and which also includes the header.php file 2. when the form is submitted on the addproduct.php it goes to the database processing script called addproduct-func.php, 3. the addproduct-func.php page has a conditional that checks to see if the database query succeeded if so it redirects using the header function back to addproduct.php. however what I would like to implement is some form validation and checking before it gets submitted to the addproduct-func.php and only if validation and form checking passes then goto addproduct-func.php. I also would like to output a little success msg informing the user that the record had been added to the database just above the addproduct.php form. I am using bootstrap as my css framework. Many Thanks for your time and help J
  6. Hey All I have a page where a users types in a number and using Ajax if that number exsist in the DB it will say on the same page "this record was found in the DB click here to view this record" and the opposite happens if the record does not exsist instead of view the record a link says "not found click here to create this record" now this is where I cant seem to find solutions in my Ajax books at the moment when a user clicks the link it goes to the correnponding page example "addrecord.php or viewrecord.php" what I would like is for a popup to show with the content of those pages rather than going to the seperate pages unless JS has been disabled. hope that kinda makes sense Joe
  7. Hey All, I am making a small application to help me learn, my question is this I am making a page where the users enters a number asset number that is they click submit and if that record exsists it will have a link underneath the input box saying record found click here to view details if the record does not exsist there will be a link saying record not found click here to add the record. my problem is that I dont know how to do this on one page I can do it with seperate pages but not sure how to do it on one any ideas please? Joe
  8. Hey Guys, I am having a strange issue I have a form where a user can enter there name and it will echo it out on the next page (it is a bigger script but i am doing some testing bit by bit) The form page <form action="includes/runtime.php" method="post"> <p>Asset ID: <input type="text" name="asset_id" size="15" maxlength="20" value="<?php echo $_GET['asset_id'];?>" /></p> <label>Select Hardware Type:</label><select name="hw_type"> </select> <input type="hidden" name="rma_status" size="20" maxlength="20" value="New"/> <p>Submitter Name: <input type="text" name="name" size="20" maxlength="20"/></p> <p>Fault Description: <textarea name="fault_desc" rows="20" cols="30"></textarea></p> <p><input type="submit" name="submit" value="Add Record" /></p> <input type="hidden" name="newrma" value="new"/> </form> and the runtime page code foreach ($_POST as $key => $value) { $post[$key] = $value; echo $post['name']; } basically it echos the value of name but outputs 4 copies for example if i added name john it would output JohnJohnJohnJohn I only need it to output the once any ideas J
  9. hey all, I use to have a msg output to the screen to inform the user that there file had been uploaded but i needed to add a bit of code to stop the same data been added to the database trice when the page was refreshed so I added a header redirection to the same page now the msg will not be outputted this is what I have. echo "<br>File $fileName uploaded<br>"; header("Location: http://localhost/php/upload.php"); the above snippet is my code
  10. Hey dude, that dont really help me? since there examples have hard coded mutiple input fileds for files where as mine does not mine uses jquery and php to allow for one file to be uploaded mandatory and an option to add another upload file input box if necssary. Joe
  11. Hey all, I have created an upload script that allows the user to upload a file using this same page if the user wants to upload another file at the same time they click a button and it will create an extra file upload box built using jquery. now this seems to work but I am having problems with my php code taking the upload file(s) add adding them to the database. I have attached my Code along with the javascript code that i am using. <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="author" content="ohyeah" /> <title>Untitled 1</title> <script src="includes/jquery.js" type="text/javascript"></script> <script src="includes/upload.js" type="text/javascript"></script> </head> <body> <?php /** * @author ohyeah * @copyright 2011 */ if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { foreach($_FILES['userfile']['error'] as $key => $error) { $tmpName = $_FILES['userfile']['tmp_name'][$key]; $fileName = $_FILES['userfile']['name'][$key]; $fileSize = $_FILES['userfile']['size'][$key]; $fileType = $_FILES['userfile']['type'][$key]; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } } //include 'library/config.php'; include ('includes/dbconnect.php'); $query = "INSERT INTO uploads (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysqli_query($dbc, $query); mysqli_close($dbc); echo "<br>File $fileName uploaded<br>"; } ?> <form action="upload2.php" 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" /> <div id="text"> <div ><input name="userfile[]" type="file" /></div> <!-- This is where the new file field will appear --> </div> <input type="button" id="add-file-field" name="add" value="Add input field" /> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload " /></td> </tr> </table> </form> </body> </html> the java script code $(document).ready(function(){ // This will add new input field $("#add-file-field").click(function(){ $("#text").append("<div class='added-field'><input name='userfile[]' type='file' /><input type='button' class='remove-btn' value='Remove Field' /></div>"); }); // The live function binds elements which are added to the DOM at later time // So the newly added field can be removed too $(".remove-btn").live('click',function() { $(this).parent().remove(); }); }); thanks for your help
  12. thanks all for your help and PFMaBiSmAd thanks for clearing that up for me
  13. Hey all this is my source html source code that is <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>View File</title> <style type="text/css" title="text/css" media="all"> .error { font-weight: bold; color: #C00 } </style> </head> <body> <p>Click a file to download</p> <table align="center" cellspacing="5" cellpadding="5" border="1"> <tr> <td align="center"><b>File Name</b></td> <td align="center"><b>File Size</b></td> </tr> <tr> <td><a href="C:/wamp/uploads/101_LPIC1_Mega_Guide.zip">101_LPIC1_Mega_Guide.zip</a></td> <td>753kb</td> </tr> <tr> <td><a href="C:/wamp/uploads/Blue+hills.jpg">Blue+hills.jpg</a></td> <td>28kb</td> </tr> <tr> <td><a href="C:/wamp/uploads/Symfony2-QuickTour.pdf">Symfony2-QuickTour.pdf</a></td> <td>131kb</td> </tr> <tr> <td><a href="C:/wamp/uploads/Winter.jpg">Winter.jpg</a></td> <td>103kb</td> </tr> </table> </body> </html>
  14. Hey all, this kinda relates to my upload script problem but in some what way different I have now created a download script a small one that pulls the details of the files that where uploaded and places them with a link in a html table, now it creates the link ok but when I click the link nothing happens? <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>View File</title> <style type="text/css" title="text/css" media="all"> .error { font-weight: bold; color: #C00 } </style> </head> <body> <p>Click a file to download</p> <table align="center" cellspacing="5" cellpadding="5" border="1"> <tr> <td align="center"><b>File Name</b></td> <td align="center"><b>File Size</b></td> </tr> <?php /** * @author ohyeah * @copyright 2011 */ $dir = 'C:/wamp/uploads/'; $files = scandir($dir); foreach($files as $filedownload){ if(substr($filedownload, 0, 1) != '.'){ $file_size = round((filesize("$dir/$filedownload")) / 1024) . "kb"; $filedownload = urlencode($filedownload); echo "\t<tr> \t\t<td><a href=\"$dir$filedownload\">$filedownload</a></td> \t\t<td>$file_size</td> \t</tr>\n"; } } ?> </table> </body> </html>
  15. Hey MrAdam, Thanks for the tip about the file extension validation input rather than what I was doing before hand ,it worked. this is what i changed if ($_FILES['upload']['type'] == 'zip' || 'pdf') {do stuff here} Joe
  16. Hey All, I am new at PHP and have been messing around with an upload script that I built from following numerous tutorials over the net. I am trying to allow the user to upload zip files as well as pdf and images. the pdf and images all work however if the user wants to upload a zip it will not work meaning it will not accept the input nor add it to the uploads directory. I am not sure whats going on. here is my code <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Upload an Image</title> <style type="text/css" title="text/css" media="all"> .error { font-weight: bold; color: #C00 } </style> </head> <body> <?php # Script 10.3 - upload_image.php // Check if the form has been submitted: if (isset($_POST['submitted'])) { // Check for an uploaded file: if (isset($_FILES['upload'])) { // Validate the type. Should be JPEG or PNG. $allowed = array ('application/zip','application/pdf', 'image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'); if (in_array($_FILES['upload']['type'], $allowed)) { // Move the file over. if (move_uploaded_file ($_FILES['upload']['tmp_name'], "C:/wamp/uploads/{$_FILES['upload']['name']}")) { echo '<p><em>The file has been uploaded!</em></p>'; } // End of move... IF. } else { // Invalid type. echo '<p class="error">Please upload a JPEG or, PDF Or, PNG image.</p>'; } } // End of isset($_FILES['upload']) IF. // Check for an error: if ($_FILES['upload']['error'] > 0) { echo '<p class="error">The file could not be uploaded because: <strong>'; // Print a message based upon the error. switch ($_FILES['upload']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'No temporary folder was available.'; break; case 7: print 'Unable to write to the disk.'; break; case 8: print 'File upload stopped.'; break; default: print 'A system error occurred.'; break; } // End of switch. print '</strong></p>'; } // End of error IF. // Delete the file if it still exists: if (file_exists ($_FILES['upload']['tmp_name']) && is_file($_FILES['upload']['tmp_name']) ) { unlink ($_FILES['upload']['tmp_name']); } } // End of the submitted conditional. ?> <form enctype="multipart/form-data" action="upload.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="5242888888888"> <fieldset><legend>Select a JPEG or PNG image of 512KB or smaller to be uploaded:</legend> <p><b>File:</b> <input type="file" name="upload" /></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </body> </html> thanks Joe
  17. Hey all I have some old code that i did a while back but now that I am running php 6 it says the eregi function is depreciated I have tried replacing this old function with preg-match but I am unable to do so I was wondering if you all good take a look at my coding and see how i can remove the validation check altogether I have two pages the first page processes the orders <?php /* Program name: ProcessOrder.php * Description: Processes order when it's been submitted. */ session_start(); #5 include("functions_main.inc"); if(!isset($_SESSION['order_number'])) #7 { echo "No order number found<br>\n"; header("Location: ShopCatalog.php"); exit(); } if(@$_GET['from'] == "cart") #13 { include("fields_ship_info.inc"); include("single_form.inc"); exit(); } elseif(isset($_POST['Summary'])) #19 { foreach($_POST as $field => $value) #21 { if ($value == "") { $blanks[] = $field; } } if(isset($blanks)) { $message = "The following fields are blank. Please enter the required information: "; foreach($blanks as $value) { $message .="$value, "; } extract($_POST); include("fields_ship_info.inc"); include("single_form.inc"); exit(); } foreach($_POST as $field => $value) #41 { if($field != "Summary") { if(eregi("name",$field)) { if (!ereg("^[A-Za-z' -]{1,50}$",$value)) { $errors[] = "$value is not a valid name."; } } if(eregi("street",$field)or eregi("addr",$field) or eregi("city",$field)) { if(!ereg("^[A-Za-z0-9.,' -]{1,50}$",$value)) { $errors[] = "$value is not a valid address or city."; } } if(eregi("county",$field)) { if(!ereg("[A-Za-z]",$value)) { $errors[] = "$value is not a valid state."; } } if(eregi("email",$field)) { if(!ereg("^.+@.+\\..+$",$value)) { $errors[]="$value is not a valid email address."; } } if(eregi("postcode",$field)) { if(!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$value)) { $errors[] = "$value is not a valid zipcode."; } } if(eregi("phone",$field)) { if(!ereg("^[0-9)(xX -]{7,20}$",$value)) { $errors[]="$value is not a valid phone number. "; } } if(eregi("cc_number",$field)) { $value = trim($value); $value = ereg_replace(' ','',$value); $value = ereg_replace('-','',$value); $_POST['cc_number'] = $value; if($_POST['cc_type'] == "visa") { if(!ereg("^[4]{1,1}[0-9]{12,15}$",$value)) { $errors[]="$value is not a valid Visa number. "; } } elseif($_POST['cc_type'] == "mc") { if(!ereg("^[5]{1,1}[0-9]{15,15}$",$value)) { $errors[] = "$value is not a valid Mastercard number. "; } } else { if(!ereg("^[3]{1,1}[0-9]{14,14}$",$value)) { $errors[] = "$value is not a valid American Express number. "; } } } $$field = strip_tags(trim($value)); } } if(@is_array($errors)) { $message = ""; foreach($errors as $value) { $message .= $value." Please try again<br />"; } include("fields_ship_info.inc"); include("single_form.inc"); exit(); } #132 /* Process data when all fields are correct */ foreach($_POST as $field => $value) #134 { if(!eregi("cc_",$field) && $field != "Summary" ) #136 { $value = addslashes($value); $updates[] = "$field = '$value'"; } } $update_string = implode($updates,","); #142 $sql_ship = "UPDATE Customer_Order SET $update_string WHERE order_number='{$_SESSION['order_number']}'"; $cxn = connect_to_db("Vars.inc"); $result = mysqli_query($cxn,$sql_ship) or die(mysqli_error($cxn)); extract($_POST); #148 include("fields_summary.inc"); include("summary_page.inc"); } elseif(isset($_POST['Ship'])) #152 { include("fields_ship_info.inc"); include("single_form.inc"); } elseif(isset($_POST['Final'])) #157 { switch ($_POST['Final']) #159 { case "Continue Shopping": #161 header("Location: ShopCatalog.php"); break; case "Cancel Order": #164 #include("fields_cancel.inc"); #include("cancel_message.inc"); unset($_SESSION['order_number']); session_destroy(); exit(); break; case "Submit Order": #171 $cxn = connect_to_db("Vars.inc"); $sql = "UPDATE Customer_Order SET submitted='yes' WHERE order_number='{$_SESSION['order_number']}'"; $result = mysqli_query($cxn,$sql) or die("Error: ".mysqli_error($cxn)); #processCCInfo(); #177 #sendOrder(); #include("fields_accept.inc"); #179 #include("accept_message.inc"); #email(); #181 session_destroy(); #182 break; } } ?> this pages contains the fileds <?php /* File: fields_ship_info.inc * Desc: Contains arrays with the field names and form * elements for the login Web page. */ $page = array( "title" => "Food Shop Order: Shipping Information", "top" => "Food Shop Order: Shipping Information", "top2" => "Please fill in the information below", "bottom" => "Joe Moore", ); $ship_info = array("email" => "Email Address", "ship_name" => "Name", "ship_street" => "Street", "ship_city" => "City", "ship_county" => "County", "ship_postcode" => "Postcode", "phone" => "Phone", "cc_type" => "Credit Card Type", "cc_number" => "Credit Card Number", "cc_exp" => "Expiration Date" ); $cc_types = array("visa" => "Visa", "mc" => "Master Card", "amex" => "American Express" ); $length = array("email" => "55", "ship_name" => "40", "ship_street" => "55", "ship_city" => "40", "ship_postcode" => "8", "phone" => "15", "cc_number" => "20" ); $elements = array( "submit" => "Continue"); $months = array (1=> "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); $today = time("Y-m-d"); if(!isset($_POST['state'])) { $connect = connect_to_db("Vars.inc"); #47 $sql = "SELECT ship_name,ship_street,ship_city,ship_county,ship_postcode, phone,email FROM Customer_Order WHERE order_number = '{$_SESSION['order_number']}'"; $result = mysqli_query($connect,$sql) or die("Error: ".mysqli_error($connect)); $n = mysqli_num_rows($result); #54 if($n > 0) #55 { $row = mysqli_fetch_assoc($result); extract($row); } } ?>
  18. Hello all, I have an HTML form were the user can select a product number once they have done that the calling script will output the part number that they selected and show all the details that releate to that part number in a table all the details are stored in a multidimensional array, I know I am ment to use the $_POST function but i have no idea were to put it within my code? Would someone Kindly show me please? My code is shown below Joe My html form <?php /** * @author ohyeah * @copyright 2010 */ ?> <form action="output.php" method="post"> Select a Part number <input type="radio" name="id" value="AC1009"/> AC1009 <input type="radio" name="id" value="AC1010"/> AC1010 <input type="radio" name="id" value="AC1011"/> AC1011 <input type="radio" name="id" value="AC1012"/> AC1012 <input name="inventory" type="submit" value="submit"/> <input type="reset" value="Cancel"/> </form> My porcess script <html><head><title>Inventory Information</title> </head><body></body> <?php /** * @author ohyeah * @copyright 2010 */ $inventory = array ( 'AC1009'=>array('Part'=>'Hammer','Count'=>122,'Price'=>12.50 ), 'AC1010'=>array('Part'=>'Wrench','Count'=>125,'Price'=>25.30 ), 'AC1011'=>array('Part'=>'Drill','Count'=>12,'Price'=>90.50 ), 'AC1012'=>array('Part'=>'Saw','Count'=>10,'Price'=>30.50 ) ); if (isset($inventory[$id])){ echo '<font size="4" color="blue"> '; echo "Inventory Information for Part $id </font>"; echo '<table border=1> <th> ID <th> Part <th> Count <th> Price '; echo "<tr> <td> $id </td>"; echo "<td> {$inventory[$id]['Part']} </td>"; echo "<td> {$inventory[$id]['Count']} </td>"; echo "<td> {$inventory[$id]['Price']} </td></tr>"; } else { echo "Illegal part ID = $id "; } ?> </body></html>
  19. Thanks all for helping me out I shall remember what you all said for future refernce
  20. I have modifed my code on the read.php page to this. <?php //include('auth.php'); /** * @author Joe Moore * @copyright 2010 */ ?> <h1>Welcome <?php // echo $_SESSION['SESS_FIRST_NAME'];?></h1> <?php //Include the database connection details, to allow us to communicate with the database include 'dbcon.php'; $id = $_GET['id']; $guide = mysql_query("SELECT guidetext FROM guides WHERE id='$id'"); if (!$guide) { exit('<p>Error Fetching Guide Details: ' . mysql_error() . '</p>'); } while ($guide = mysql_fetch_array($guide)) { $read = $guide['guidetext']; echo "$read"; } ?> it works but I get an error which says this Warning: mysql_fetch_array() expects parameter 1 to be resource, array given in C:\wamp\www\blog\read.php on line 25
  21. Hey Jay6390 That works but it outputs an array structure which i dont want to happen, I would like it to just output the content in guidetext for example lets say guidetext had a value in the database table called "Lets begin" I would like that outputted to the screen
  22. Hello, First let me explain my problem, I have 2 pages the first page pull a list of Guide titles from a database for example if i had a guide called "Install windows" it would be pulled from the database with a link next to the guide called "read this Guide" now that works fine. the problem that i am having is when a user clicks the "Read this guide" it will goto the next page and pull the content from the database that releates to the guide. however nothing is being displayed on the next page. My code is shown below for the 2 pages and my database structure. Guides.php (1st page) <?php /** * @author Joe Moore * @copyright 2010 */ //Include the database connection details, to allow us to communicate with the database include 'dbcon.php'; echo '<p> Here are all the articles in the database </p>'; $result = @mysql_query('SELECT guidetitle, id FROM guides'); if (!$result) { exit('<p>Error performing query: ' . mysql_error() . '</p>'); } // Display the text of each guide in a paragraph //with a "Delete this Guide" link next to each while ($row = mysql_fetch_array($result)) { $id = $row['id']; $guidetitle = $row['guidetitle']; echo "<p>$guidetitle " . "<a href=read.php?id=$id>Read this guide</a></p>"; } ?> read.php (2nd page) <?php //include('auth.php'); /** * @author Joe Moore * @copyright 2010 */ ?> <h1>Welcome <?php // echo $_SESSION['SESS_FIRST_NAME'];?></h1> <?php //Include the database connection details, to allow us to communicate with the database include 'dbcon.php'; $id = $_GET['id']; $guide = mysql_query("SELECT guidetext, id FROM guides WHERE id='$id'"); if (!$guide) { exit('<p>Error Fetching Guide Details: ' . mysql_error() . '</p>'); } $guide = mysql_fetch_array($guide); ?> my database structure (table) id guidetext guidedate guidetitle author 1 This is sample text and will be updated accordinly 2010-01-08 Secure Passwords 1 2 this guide will talk abut web servers and how to i... 2010-01-08 Install web servers on windows 1 3 this guide will talk about password storage 2010-01-08 How to secure passwords 2 1 5 HOW TO INSTALL LITESPEED ON LINUX 2010-01-09 Litespeed webserver 1 Thanks - Joe
  23. Hey All, I was wondering if somone could take a look at this for me? What I am trying to do is change the font colour of the text depending on what the user selected for example I have to pages one page that has the code for the radio buttons the other page that processes it now if the user slects the red radio button i want the next page to output the name of the radio button they selected in that colour so being red. my code is shown below Form Page <?php /** * @author Joe Moore * @copyright 2009 */ ?> <form action="script.php" method="POST"> <input type="radio" name="colours" checked value="red"/> Red<br /> <input type="radio" name="colours" value="blue"/> Blue<br /> <input type="radio" name="colours" value="green"/> Green<br /> <input type="submit" value="GO"/> </form> Process Page (script.php) <?php /** * @author Joe Moore * @copyright 2009 */ echo "<font color="$_POST['colours']"></font>"; ?> all I get is an error phase error msg
  24. Thats what I am trying to do my html form is on one page and this page is called the process.php page
×
×
  • 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.