Jump to content

farban

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

farban's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello Got a problem where I want to get prepared statements to work through adding parameters, something like this <?php class Prepared_Statement extends Handle_DB { private $query; private $bind_result; private $stmt; public function set_PS_query($query) { $this->query = $query; } public function setup_PS($bindresult) { $this->stmt = parent::connect_DB()->stmt_init(); $this->stmt->prepare($this->query); $this->stmt->execute(); $this->stmt->bind_result($bindresult); } public function show_PS_results($result) { while($this->stmt->fetch()) { return $result; } } public function close_PS() { $this->stmt->close(); } } $preS = new Prepared_Statement(); $preS->set_PS_query("SELECT user_name FROM usertest"); $preS->setup_PS("user_name"); echo $preS->show_PS_results("user_name"); $preS->close_PS(); ?> The problem is that it throws up Undefined variable: user_name errors when i run the script. I know why this is the case, how can I pass a variable into the prepared statement without it saying its undefined??
  2. can i just say i know its off topic butwould it cost money for a client to upgrade php4 to php5
  3. Well for the echo it dosent print out the varibles so it should echo $artist - $title - $url instead its echoing - - so its not outputting the varibles
  4. i cant change hosts or upgrade the server as its for a client and uni project so i cant really tell the client to upgrade im afraid here is the code <?php $doc = domxml_open_mem(); $doc = domxml_open_file("Playlist.xml"); $musiclist = $doc->get_elements_by_tagname( "mp3" ); foreach( $musiclist as $song ) { $artists = $song->get_elements_by_tagname( "artist" ); $artist=htmlentities(utf8_decode($artist->nodeValue)); $titles= $song->get_elements_by_tagname( "title" ); $title= $titles->nodeValue; $urls = $song->get_elements_by_tagname( "url" ); $url = $urls->nodeValue; echo "<b>$artist - $title - $url\n</b><br>"; } ?> just really need some solution to this ...only need to make the title artist and url appear
  5. sorry i just wasnt sure if this was different enough to warrent a new thread
  6. just wondering what is it i need to do to convert this line of code to php 4 $title= $titles->item(0)->nodeValue;
  7. can anyone help me please?
  8. Hey i have a T_OBJECT_OPERATOR syntax error when opening mp3.php page. I know its because its php 4 and dosent understand the code but i want to fix this problem without upgrading to php 5. any help please? mp3.php page <?php $doc = new DOMDocument(); $doc->load( 'Playlist.xml' ); $musiclist = $doc->getElementsByTagName( "mp3" ); foreach( $musiclist as $song ) { $artists = $song->getElementsByTagName( "artist" ); $artist = $artists->item(0)->nodeValue; $titles= $song->getElementsByTagName( "title" ); $title= $titles->item(0)->nodeValue; $urls = $song->getElementsByTagName( "url" ); $url = $urls->item(0)->nodeValue; echo "<b>$artist - $title - $url\n</b><br>"; } ?>
  9. I have two php files that simply need modifing so that they communicate with this xml file <?xml version="1.0" encoding="UTF-8" ?> <songs> <song filename="The Birthday Massacre - Nothing And Nowhere - 06 - Video Kid.mp3" track="Video Kid" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 07 - Over.mp3" track="Over" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 08 - Broken.mp3" track="Broken" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 09 - The Dream.mp3" track="The Dream" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 01 - Happy Birthday.mp3" track="Happy Birthday" artist="The Birthday Massacre" album="Nothing And Nowhere" /> </songs> here is the two php files upload.php <h1>Jukebox Playlist</h1> <p>Enter the Artist and Title names as you want them to appear on the jukebox. It'll take a few minutes to upload a song after you click submit, so leave it and don't close the page until you see it added to the Current Entries list.</p> <form action="playlistaction.php" method="post" enctype="multipart/form-data"> <table> <tr> <td colspan="2"class="labelcell"><label for="artist">Artist:</label></td> <td colspan="2"class="fieldcell"><input type="text" id="artist" name="artist" tabindex="1"/></td> </tr> <tr> <td colspan="2"class="labelcell"><label for="title">Title:</label></td> <td colspan="2"class="fieldcell"> <input type="text" id="title" name="title" tabindex="2"/><br /> </td> </tr> <!-- <tr> <td colspan="2"class="labelcell"><label for="path">URL:</label></td> <td colspan="2"class="fieldcell"> <input type="text" id="url" name="url" tabindex="3"/> <br /> </td> </tr>--> <tr> <td colspan="2"class="labelcell"><label for="userfile">Song Upload</label></td> <td colspan="2"><input name="userfile" type="file" id="userfile" tabindex="4"></td></tr> </td> </tr> <td colspan="4"><input type="submit" name="upload" class="box" value="Submit" tabindex="5" /></td> </table> </fieldset> </form> <h2>Current entries:</h2> <p>Artist - Title - URL</p> <?php $xml = simplexml_load_file("..songs/playlist.xml"); foreach($xml->songs[0]->attributes() as $a => $b) { echo $a,'="',$b,"\"</br>"; } ?> ?> playlistaction.php <?php $uploadDir = 'Bulrush\songs'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } } $song = array( 'track' => $_POST['track'], 'artist' => $_POST['artist'], 'album' => $_POST['album'], 'song filename' => $filePath, ); $doc = new DOMDocument(); $doc->load( 'playlist.xml' ); $doc->formatOutput = true; $r = $doc->getElementsByTagName("songs")->item(0); $title = $doc->createElement("track"); $title->appendChild( $doc->createTextNode( $song["track"] ) ); $b->appendChild( $title ); $artist = $doc->createElement("artist"); $artist->appendChild( $doc->createTextNode( $song["artist"] ) ); $b->appendChild( $artist ); $artist = $doc->createElement("album"); $artist->appendChild( $doc->createTextNode( $song["album"] ) ); $b->appendChild( $artist ); $url = $doc->createElement("song filename"); $url->appendChild( $doc->createTextNode( $song["song filename"] ) ); $b->appendChild( $url ); $r->appendChild( $b ); $doc->save("player.xml"); header("Location: {$_SERVER['HTTP_REFERER']}"); ?> i have tried to change it and modify it so it works with the xml but i just dont know what to change. its important that its changed to the xml file
  10. aha it says that Notice: Undefined index: user_id in C:\xampp\htdocs\testsite\community\viewprofile.php on line 44 Notice: Undefined index: user_id in C:\xampp\htdocs\testsite\community\viewprofile.php on line 75 for viewprofile.php any help please?
  11. doing something like this in viewprofile.php works fine cause its static $q = " SELECT user.user_first_name, user.user_surname, user.user_photo, user.user_age, user.user_sex, user.user_city, user.user_home_phone, user.user_mobile_phone, user.user_profession, user.user_specialist_area, user.user_email, user.user_password, user.user_username FROM user WHERE user.user_id=3"; but i need it to be dynamic to represent the user that has been selected $q = " SELECT user.user_first_name, user.user_surname, user.user_photo, user.user_age, user.user_sex, user.user_city, user.user_home_phone, user.user_mobile_phone, user.user_profession, user.user_specialist_area, user.user_email, user.user_password, user.user_username FROM user WHERE user.user_id='".$_GET['user_id']."'"; this code dosent work. really need some help soo close to fixing this
  12. I have done the changes and it seems to be navigating to the correct id numbers which is great but nothting appears on the viewprofile.php page. arghh so close !! viewprofile.php <?php session_start(); if (!isset($_SESSION['user_id'])) { $url = absolute_url(); header("Location: $url"); exit(); } include("includes/start.php"); require_once("includes/_connect.inc.php"); if (isset($_GET['user_id'])) { $q = " SELECT user.user_first_name, user.user_surname, user.user_photo, user.user_age, user.user_sex, user.user_city, user.user_home_phone, user.user_mobile_phone, user.user_profession, user.user_specialist_area, user.user_email, user.user_password, user.user_username FROM user WHERE user.user_id= '".$_GET['user_id']."'"; $result = @mysqli_query($dbc, $q); if ($result) { while ($row =mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<table class='pictable'> <tr> <td><img src='images/".$row[user_photo]."' width='100%' height='100%'></img></td> </tr></table> <table class='profiletable'> <tr><td>First Name</td> <td>".$row[user_first_name]."</td> </tr> <tr><td>Surname</td> <td>".$row[user_surname]."</td></tr> <tr><td>Age</td> <td>".$row[user_age]."</td></tr> <tr><td>Email</td> <td>".$row[user_email]."</td></tr> <tr><td>Sex</td> <td>".$row[user_sex]."</td></tr> <tr><td>City</td><td>".$row[user_city]."</td></tr> <tr><td>Home Phone</td> <td>".$row[user_home_phone]."</td></tr> <tr><td>Mobile Phone</td> <td>".$row[user_mobile_phone]."</td></tr> <tr><td>Profession</td> <td>".$row[user_profession]."</td></tr> <tr><td>Specialist area</td> <td>".$row[user_specialist_area]."</td></tr> </table>"; } if (isset($_SESSION ['user_id']) && ($_SESSION ['user_id'] == $_GET['user_id'])) { echo "<div class='usereditprofile'><a href='editprofile.php'>Edit Profile</a></div>"; } mysqli_free_result($result); } } include("includes/footer.php"); ?>
  13. ill post up the code for the userlist.php <?php session_start(); if (!isset($_SESSION['user_id'])) { $url = absolute_url(); header("Location: $url"); exit(); } include("includes/start.php"); require_once("includes/_connect.inc.php"); echo "<h1>The user list</h1><p>Listing the members of the site</p>"; $id = $_GET['user_id']; $display= 2; if (isset($_GET['p']) && is_numeric($_GET['p'])) { $pages = $_GET['p']; } else { $q = " SELECT COUNT(user_id) FROM user"; $result = @mysqli_query($dbc, $q); $row = mysqli_fetch_array($result, MYSQLI_NUM); $records = $row [0]; if ($records > $display) { $pages = ceil ($records/$display); } else { $pages= 2; } } if (isset($_GET['s']) && is_numeric ($_GET['s'])) { $start =$_GET['s']; } else { $start =0; } $q = " SELECT user.user_first_name, user.user_surname, user.user_photo, user.user_age, user.user_sex, user.user_city, user.user_home_phone, user.user_mobile_phone, user.user_profession, user.user_specialist_area, user.user_email, user.user_password, user.user_username FROM user ORDER BY user.user_id ASC LIMIT $start, $display"; $result = @mysqli_query($dbc, $q)or die("Error: ".mysqli_error($dbc)); while ($row =mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<div class='userlist'><table class='pictable'> <tr> <td><img src='images/".$row[user_photo]."' width='100%' height='100%'></img></td> </tr></table> <table class='profiletable'> <tr><td>First Name</td> <td>".$row[user_first_name]."</td> </tr> <tr><td>Surname</td> <td>".$row[user_surname]."</td></tr> <tr><td>Age</td> <td>".$row[user_age]."</td></tr> <tr><td>Email</td> <td>".$row[user_email]."</td></tr> <tr><td>Sex</td> <td>".$row[user_sex]."</td></tr> <tr><td>City</td><td>".$row[user_city]."</td></tr> <tr><td>Home Phone</td> <td>".$row[user_home_phone]."</td></tr> <tr><td>Mobile Phone</td> <td>".$row[user_mobile_phone]."</td></tr> <tr><td>Profession</td> <td>".$row[user_profession]."</td></tr> <tr><td>Specialist area</td> <td>".$row[user_specialist_area]."</td></tr> <tr><td><a href='viewprofile.php?='".$id."'>View Profile</a></tr></td> </table></div>"; } mysqli_free_result($result); mysqli_close($dbc); if ($pages > 1) { echo'<div class="userlinklist"><p>'; $current_page =($start/$display) +1; if ($current_page !=1) { echo '<a href="userlist.php?s='.($start - $display).'&p='.$pages.'">Previous</a>'; } for ($i =1; $i <= $pages; $i++) { if ($i !=$current_page) { echo ',<a href="userlist.php?s='.(($display * ($i -1))).'&p='.$pages.'">'.$i.'</a>,'; } else { echo $i.''; } } if ($current_page !=$pages) { echo '<a href="userlist.php?s='.($start + $display).'&p'.$pages.'">Next</a>'; } echo '</p></div>'; } include("includes/footer.php"); ?>
  14. Got a userlists.php script that paginates all the users of a site. When clicking on view profile on a user it will direct to a veiwprofile.php which will display all the info of that user. I cant explain very well in detail but i want it so that the url represents the user id so that the veiwprofile.php page is dynamic and it will show the user that was selected from the userlist.php page. i have this so far but when i click on view profile all i get is a blank page userlist.php <tr><td><a href='viewprofile.php?='".$id."'>View Profile</a></tr></td> viewprofile.php <?php session_start(); if (!isset($_SESSION['user_id'])) { $url = absolute_url(); header("Location: $url"); exit(); } include("includes/start.php"); require_once("includes/_connect.inc.php"); if (isset($_GET['user_id'])) { $q = " SELECT user.user_first_name, user.user_surname, user.user_photo, user.user_age, user.user_sex, user.user_city, user.user_home_phone, user.user_mobile_phone, user.user_profession, user.user_specialist_area, user.user_email, user.user_password, user.user_username FROM user WHERE user.user_id= '".$_GET['user_id']."'"; $result = @mysqli_query($dbc, $q); if ($result) { while ($row =mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<table class='pictable'> <tr> <td><img src='images/".$row[user_photo]."' width='100%' height='100%'></img></td> </tr></table> <table class='profiletable'> <tr><td>First Name</td> <td>".$row[user_first_name]."</td> </tr> <tr><td>Surname</td> <td>".$row[user_surname]."</td></tr> <tr><td>Age</td> <td>".$row[user_age]."</td></tr> <tr><td>Email</td> <td>".$row[user_email]."</td></tr> <tr><td>Sex</td> <td>".$row[user_sex]."</td></tr> <tr><td>City</td><td>".$row[user_city]."</td></tr> <tr><td>Home Phone</td> <td>".$row[user_home_phone]."</td></tr> <tr><td>Mobile Phone</td> <td>".$row[user_mobile_phone]."</td></tr> <tr><td>Profession</td> <td>".$row[user_profession]."</td></tr> <tr><td>Specialist area</td> <td>".$row[user_specialist_area]."</td></tr> </table>"; } if (isset($_SESSION ['user_id'])) { echo "<div class='usereditprofile'><a href='editprofile.php'>Edit Profile</a></div>"; } mysqli_free_result($result); } } include("includes/footer.php"); ?>
×
×
  • 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.