Jump to content

jamesyrawr

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jamesyrawr's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a photo album style gallery to build and i'm finding it dificult to list all the table names (these are names of photo albums) and then enter the data into a seperate query for each album name (these will change often so i cant keep updating the file as normal. this will then post all the data to the xml file and show the set of photos in the individual albums in a flash file. can anyone help me where im going wrong at all? <?php $dbname = 'cablard'; if (!mysql_connect('localhost', 'cablard', '')) { echo 'Could not connect to mysql'; exit; } $sql = "SHOW TABLES FROM $dbname"; $result = mysql_query($sql); if (!$result) { echo "DB Error, could not list tables\n"; echo 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { echo "Table: {$row[0]}\n"; } mysql_free_result($result); $query = "SELECT * FROM photo ORDER BY id DESC"; $result2 = mysql_query ($query) or die ("Error in query: $query. ".mysql_error()); while ($row = mysql_fetch_array($result2)) { echo " <image> <date>".$row['date']."</date> <title>".$row['title']."</title> <desc>".$row['description']."</desc> <thumb>".$row['thumb']."</thumb> <img>".$row['image']."</img> </image> "; } ?> Thanks James
  2. I'm not sure if this is possible but is it possible to update an xml file using php which in turn the xml updates the flash file? so say the user enters some data into the database the database is then read by the php which sends to xml and then updates the flash file? hope that makes some form of sense and if it does exist or some form of system that does this could you please give me some guidance in the right direction Thanks James
  3. can someone please give me some guidance on how to do this please I am wanting to create a status updating type application on my site and i have this idea in my head i want it to retrive and print the last 3 posts (max ids) made by the user if someone could give me some example code please and i can hopefully work from that. Thanks James
  4. i seem to get this error in my code when i try to retrieve the location of the image stored Parse error: parse error in C:\wamp\www\uniwork\guitars.php on line 48 print "<td> <img src="products/guitars/'.$row['prod_image'].'" /></td>"; that piece of code doesnt seem to be working and i cant see why can someone help fix me fix it please? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Flerp Guitars - Guitars</title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style/index.css" media="screen" /> </head> <body> <div id="wrap"> <div id="header"> <img src="images/logo.png" alt="Logo" height="150px" width="150px"/> </div> <div id="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="#">About</a></li> <li><a href="products.php">Products</a></li> <li><a href="myaccount.php">My Account</a></li> <li><a href="#">Accessability</a></li> </ul> </div> <div id="content"> <div class="right"> <h2><a href="#">Guitars</a></h2> <?php //To demonstrate the use of included files //We keep repeating the connection details. Lets put them in a separate file so we can re-use easily include ("include/connect.php"); // Create a query $query = "SELECT * FROM products ORDER BY prod_id ASC"; //Run the query on the table through the connection $result = mysql_query ($query) or die ("Error in query: $query. ".mysql_error()); //Display using tags this time print "<table border = 12 >"; print " <tr><th>Product ID</th><th>Product Name</th><th>Product Price</th><th>Product Description</th><th>Product Colour</th></tr>"; while ($row = mysql_fetch_array($result)) { print " <tr>"; print "<td> <img src="products/guitars/'.$row['prod_image'].'" /></td>"; print " <td>" . $row["prod_id"] . "</td>"; print " <td>" . $row["prod_name"]. "</td>"; print " <td>£" . $row["prod_price"] . "</td>"; print " <td>" . $row["prod_desc"]. "</td>"; print " <td>" . $row["prod_colour"] . "</td>"; print " </tr>"; } print "</table>"; ?> <p><strong> The links here are only for testing purposes, once the admin section is coded properly these will be stored in there and only accessible by the admin account.</strong></p> <a href="insertrow.php">Click Here to insert New details</a><br/> <a href="deleterow.php">Click Here to delete details</a> <a href="editrow.php">Click Here to amend the details</a> <h2><a href="#">other ideas</a></h2> <div class="footer"> <?php $after = "Good afternoon! "; $late = "Go To Bed! "; $evening = "Good evening! "; $morn = "Good morning "; $current_time = date('G'); if ($current_time >= 12 && $current_time <= 16) { echo $after; } elseif ($current_time >= 1 && $current_time <= 5) { echo $late; } elseif ($current_time >= 17 && $current_time <= 24) { echo $evening; } elseif ($current_time >= 6 && $current_time <= 11) { echo $morn; } echo"<br/>"; echo"The current time is "; echo(date("G")); echo":"; echo(date("i")); echo":"; echo(date("s")); echo" "; echo(date("A")); ?> </div> </div> <div class="left"> <h2>My Cart :</h2> </div> </div> <div style="clear: both;"> </div> </div> </body> </html>
  5. thanks but it seems to be one error after another after making the adjustment i get this Notice: Undefined index: id in C:\wamp\www\uniwork\include\updatedata.php on line 4
  6. ahh thanks learned something there but now im getting this error Parse error: parse error in C:\wamp\www\uniwork\include\updatedata.php on line 4 in this piece of code <?php //edit_data.php include "connect.php"; $prod $_GET['id']; $order = "UPDATE products SET prod_name='prodname', prod_price='prodprice', prod_desc='proddesc', prod_colour='prodcolour' WHERE prod_id='$prod'"; mysql_query($order); header("location:updatedata.php"); ?>
  7. it still doesn't seem to have fixed it thanks though
  8. here are the three pages i am using to alter information stored in my database editrow.php <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table> <tr> <td align="center">EDIT DATA</td> </tr> <tr> <td> <table border="1"> <?php include"include/connect.php";//database connection $order = "SELECT * FROM products"; $result = mysql_query($order); while ($row=mysql_fetch_array($result)){ print " <td>" . $row["prod_id"] . "</td>"; print " <td>" . $row["prod_name"]. "</td>"; print " <td>" . $row["prod_price"] . "</td>"; print " <td>" . $row["prod_desc"]. "</td>"; print " <td>" . $row["prod_colour"] . "</td>"; print ("<td><a href=\"editform.php?id=$row[prod_id]\">Edit</a></td></tr>"); } ?> </table> </td> </tr> </table> </body> </html> then editform.php <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table border=1> <tr> <td align=center>Form Edit Employees Data</td> </tr> <tr> <td> <table> <?php include "include/connect.php";//database connection $id = $_GET['id']; $order = "SELECT * FROM products WHERE prod_id='$id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?> <form method="post" action="include/updatedata.php"> <input type="hidden" name="prodid" value="<? echo "$row[prod_id]"?>"> <tr> <td>Name</td> <td> <input type="text" name="prodname" size="20" value="<?php echo "$row[prod_name]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="prodprice" size="40" value="<?php echo "$row[prod_price]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="proddesc" size="40" value="<?php echo "$row[prod_desc]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="prodcolour" size="40" value="<?php echo "$row[prod_colour]"?>"> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit value" value="Edit"> </td> </tr> </form> </table> </td> </tr> </table> </body> </html> now here it all goes weird i get this error Notice: Undefined index: $id in C:\wamp\www\uniwork\include\updatedata.php on line 4 but without it it doesnt know how to get the information from the previous form. include/updatedata.php <?php //edit_data.php include "connect.php"; $id=$_GET['$id']; $order = "UPDATE products SET prod_name='prodname', prod_price='prodprice', prod_desc='proddesc', prod_colour='prodcolour' WHERE prod_id='$id'"; mysql_query($order); header("location:updatedata.php"); ?>
  9. thanks for that i had made an error in my coding and typed one of the field names differently too how it was in my database too. but now im getting a new error in it Notice: Undefined index: price in C:\wamp\www\unisite\products.php on line 13 <?php if(isset($_GET['action']) && $_GET['action'] == "add"){ $id = intval($_GET['id']); if(isset($_SESSION['cart'][$id])){ $_SESSION['cart'][$id]['quantity']++; } else { $sql2 = "SELECT * FROM products WHERE id_prod = $id "; $query2 = mysql_query($sql2); if(mysql_num_rows($query2) != 0){ $row2 = mysql_fetch_array($query2); $_SESSION['cart'][$row2['id_prod']] = array("quantity" => 1, "price" => $row2['price']); } else { $message = "This product id is invalid"; } } } ?> <h2 class="message"> <?php if(isset($message)){echo $message;}?> </h2> <h1>Products page</h1> <table> <tr> <th>Name</th> <th>Description</th> <th>Price</th> <th>Action</th> </tr> <?php $sql = "SELECT * FROM products ORDER BY name ASC"; $query = mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ ?> <tr> <td><?php echo $row['name']; ?> </td> <td><?php echo $row['prod_description']; ?> </td> <td>£<?php echo $row['prod_price']; ?> </td> <td><a href="index.php?page=products&action=add&id=<?php echo $row['id_prod']; ?>">add to cart</a></td> </tr> <?php /** * @author James Bell * @copyright 2010 */ } ?> </table>>
  10. I seem to get this error message when I run this please can someone help? Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\unisite\products.php on line 11 I can't figure this out at all <?php if(isset($_GET['action']) && $_GET['action'] == "add"){ $id = intval($_GET['id']); if(isset($_SESSION['cart'][$id])){ $_SESSION['cart'][$id]['quantity']++; } else { $sql2 = "SELECT * FROM products WHERE prod_id = [$id] "; $query2 = mysql_query($sql2); if(mysql_num_rows($query2) != 0){ $row2 = mysql_fetch_array($query2); $_SESSION['cart'][$row2]['prod_id'] = array("quantity" =>1, "price" => $row2['price']); } else { $message = "This product id is invalid"; } } } ?> <h2 class="message"> <?php if(isset($message)){echo $message;}?> </h2> <h1>Products page</h1> <table> <tr> <th>Name</th> <th>Description</th> <th>Price</th> <th>Action</th> </tr> <?php $sql = "SELECT * FROM products ORDER BY name ASC"; $query = mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ ?> <tr> <td><?php echo $row['name']; ?> </td> <td><?php echo $row['prod_description']; ?> </td> <td>£<?php echo $row['prod_price']; ?> </td> <td><a href="index.php?page=products&action=add&id=<?php echo $row['id_prod']; ?>">add to cart</a></td> </tr> <?php /** * @author James Bell * @copyright 2010 */ } ?> </table>
  11. I'll take it from there then Thanks
  12. basically i'm a student living with 5 other people who are not very computer literate im wanting find out if its possible to build a simple webpage that will log onto the router and display the pc names (or assign it to a name) then change their colour between red orange and green depending on their NAPT Active Sessions. could someone please tell me if its possible and if so point me in some form of direction that will help me build this . Thanks James
  13. I'm building a site for a uni project and i seem to be getting these errors back from it this script allows the user to update their info once they have logged in so if you notice anything else i need please say the errors i get are: Notice: Undefined index: firstname in C:\wamp\www\flerp\update_conn.php on line 14 Notice: Undefined index: lastname in C:\wamp\www\flerp\update_conn.php on line 15 Notice: Undefined index: email in C:\wamp\www\flerp\update_conn.php on line 16 <?php $host="localhost"; $username="root"; $password=""; $db_name="flerpusers"; $tbl_name="users"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $sql = "UPDATE `$tbl_name` SET `firstname` = '$firstname',`lastname` = '$lastname',`email` = '$email'"; mysql_query($sql) or die ("Error: ".mysql_error()); echo "Database updated. <a href='editinfo.php'>Return to edit info</a>"; ?>
  14. Was database issues :-\ its all sorted now but i changed $result = mysql_result($get, $con); back too $result = mysql_result($get, 0); and it seems to be working again Thanks
  15. Thanks Pengu, but i tried your change and i still got the same result: Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\Isis\login.php on line 16
×
×
  • 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.