Jump to content

Search the Community

Showing results for tags 'database'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello there; i'd like to make it possible to write all the inputs i write with this text fields but make it in a single row (on a textarea), and make it possible to add multiple "events" in my website instead of one! For example: FIRST ROW IN TEXTAREA: Date - Local Team - Away Team - RatioLocal - Draw - RatioAway - SportID - League SECOND ROW IN TEXTAREA: Date - Local Team - Away Team - RatioLocal - Draw - RatioAway - SportID - League This would be a textarea example: 2013/04/03 21:00 Bolivar The Strongest 2.20 3.20 2.88 1 LFP 2013/04/03 21:00 La Paz Oriente Petrolero 4.33 3.50 1.73 1 LFP 2013/04/03 21:00 Wilstermann Universitario 1.91 3.40 3.60 1 LFP Here are the files i use; you will get my idea as soon as you see them Agregar.php: http://pastebin.com/xeTyjrX8 Config.php: http://pastebin.com/Tyb8SXuQ Please if you need more information ask me about it! Thanks a lot for your help!
  2. Hey guys, I'll try to keep this short and simple. I've spent hours upon hours (probably 30-40+ over the week) trying to decide the best and most secure route to take with php sessions, I wouldn't trouble the community for help if I haven't put the time into it myself. After looking around I have come across a basic thought: - Check if session is already active - Set name and Params - Start Session - Check user_agent\ip (I'm not pushing this so much other than letting logged in users be aware of another device) - Regenerate Id and allow old Session id to work for a minute or so - Write encrypted data - Read encrypted data Pretty much I'm stuck on Regenerating the Id, I see how others are doing it but i guess i'm intimidated by it. Also, I have seen a few others who connect to the database to update regenerate id and update every write to store data. Performance wise is this worth it? I know if you're working with multiple servers this can benefit passing the session data, but if this is the case.
  3. Hello, New here so apologies if I commit any rule breaks regarding posting. I have been given basic javascript functions with in a HTML page that is supposed to fetch values from a already created database and input these values into the table on the page. Please see this link as an example: http://www.eng.nene.ac.uk/~10406206/CSY2028/Ajax/Ajax.html As you can see there is a table with headers. When the 'Load Database' button is clicked the function is supposed to load the database values into the correct cells. However this does not happen. There is an alert which displays correct information from the database but the values do not get entered into the table? I need to know why this is the case as I have no idea where to go to fix this. Edit: The alert was displaying my database values but now it is not. No errors displaying in the console. I am new to Javascript and Ajax coding so I apologise in advance. Below is the Javascript Functions. <script language="Javascript"> var xmlHttpReq = false; var xmlHttpReq2 = false; var xmlHttpReq3 = false; function appendRecord (id, carname, fueltype, transmission, enginesize, doors, total, available) { //rowcount ++; //if (firstname == "") return; mytable = document.getElementById ("DBTable"); mycurrent_row = document.createElement ("tr"); mycurrent_row.setAttribute ("id", "DB"+id); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (id); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (carname); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (fueltype); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (transmission); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (enginesize); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (doors); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (total); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); currenttext = document.createTextNode (available); mycurrent_cell.appendChild (currenttext); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); mycurrent_input = document.createElement ("input"); mycurrent_input.setAttribute ("type", "button"); mycurrent_input.setAttribute ("value", "modify"); mycurrent_input.setAttribute ("onclick", "modifyOrUpdateRecord (" + id + ", this)"); mycurrent_cell.appendChild (mycurrent_input); mycurrent_row.appendChild (mycurrent_cell); mycurrent_cell = document.createElement ("td"); mycurrent_input = document.createElement ("input"); mycurrent_input.setAttribute ("type", "button"); mycurrent_input.setAttribute ("value", "delete"); mycurrent_input.setAttribute ("onclick", "deleteRecord (" + id + ")"); mycurrent_cell.appendChild (mycurrent_input); mycurrent_row.appendChild (mycurrent_cell); mytable.appendChild (mycurrent_row); } function loadDatabaseRecordsCallback () { if (xmlHttpReq.readyState == 4) { alert ("From Server (Load Records):\n" + xmlHttpReq.responseText); var record = xmlHttpReq.responseXML.getElementsByTagName('record'); var s = ""; for (var i = 0; i < record.length; i ++) { var rec = record[i]; var id = rec.getElementsByTagName("ID")[0].firstChild.data; var carname = rec.getElementsByTagName("CARNAME")[0].firstChild.data; var fueltype = rec.getElementsByTagName("FUELTYPE")[0].firstChild.data; var transmission = rec.getElementsByTagName("TRANSMISSION")[0].firstChild.data; var enginesize = rec.getElementsByTagName("ENGINESIZE")[0].firstChild.data; var doors = rec.getElementsByTagName("DOORS")[0].firstChild.data; var total = rec.getElementsByTagName("TOTAL")[0].firstChild.data; var available = rec.getElementsByTagName("AVAILBLE")[0].firstChild.data; appendRecord (id, carname, fueltype, transmission, enginesize, doors, total, available); } } } function loadDatabaseRecords () { // Mozilla/Safari if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } alert ("To Server (Load Records):\n\nload.php"); xmlHttpReq.open('GET', "load.php", true); xmlHttpReq.onreadystatechange = loadDatabaseRecordsCallback; xmlHttpReq.send(null); } The loaddatabaserecords function calls the load.php file which is below <?php $link = mysql_connect ("194.81.104.22", "xxxx", "xxxxx"); mysql_select_db ("db10406206"); $query = "SELECT * from XYZ"; $result = mysql_query ($query); header ("Content-Type: application/xml"); print ("<?xml version=\"1.0\" ?>"); print "\n<database>\n"; for ($i = 0; $i < mysql_num_rows ($result); $i ++) { $row = mysql_fetch_object ($result); print " <record>\n"; print " <id>$row->ID</id>\n"; print " <carname>$row->CARNAME</carname>\n"; print " <fueltype>$row->FUELTYPE</fueltype>\n"; print " <transmission>$row->TRANSMISSION</transmission>\n"; print " <enginesize>$row->ENGINESIZE</enginesize>\n"; print " <doors>$row->DOORS</doors>\n"; print " <total>$row->TOTAL</total>\n"; print " <available>$row->AVAILABLE</available>\n"; print " </record>\n"; } print "</database>\n"; mysql_close ($link); ?> Finally this is the html table etc etc. <form name="f1"> <input value="Load Database" type="button" onclick='JavaScript:loadDatabaseRecords()'></p> </form> <table id="DBTable" border="2"> <tr> <td width="20">ID</td> <td width="100">Car Name</td> <td width="100">Fuel Type</td> <td width="100">Transmission</td> <td width="80">Engine size</td> <td width="20">Doors</td> <td width="20">Total</td> <td width="20">Available</td> </tr> <form name="myform"> <tr> <td><input type="text" name="id"></td> <td><input type="text" name="carname"></td> <td><input type="text" name="fueltype"></td> <td><input type="text" name="transmission"></td> <td><input type="text" name="enginesize"></td> <td><input type="text" name="doors"></td> <td><input type="text" name="total"></td> <td><input type="text" name="available"></td> <td colspan="2"><input type="button" value="add" onClick="JavaScript:addNewRecord()"></td> <td colspan="2"><input type="checkbox" value="update" onClick="JavaScript:updateRecord()"></td> <td colspan="2"><input type="checkbox" value="delete" onClick="JavaScript:deleteRecord()"></td> </tr> </form> </table> So, I just want to know whats going wrong. I have spent so many hours researching how to get my database values into the html table. The only responses I have had so far is to display the data in other ways etc. However, i need to display the values in the table as there is other functions that will use the information. Any help would be greatly appreciated. Thanks. Joey
  4. Hey Guys, I am in the beginning stages of creating a user login / register system for my website. currently, i am working on the conditionals to make sure the information logged in is proper , either matching the DB of my users or spitting an error array , letting my users know that either they need to enter both a valid username & pass or that the info entered does not match the Database. i have created a few functions that clean up the $_POST variables using mysql_real_escape_string: and my main function login(); function sanitize($data) { return mysql_real_escape_string($data); } function user_id_from_username($username){ $username = sanitize($username); return (mysql_result(mysql_query(" SELECT `user_id` FROM `users` WHERE `username`= '$username'"), 0 , 'user_id')); } function login($username, $password){ $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); return(mysql_result(mysql_query(" SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false; } and the conditionals to check the parameters given: if (empty($_POST) === false) { $username = $_POST['loginname']; $password = $_POST['loginpass']; if (empty($username) === true || empty($password) === true) { $errors[] = 'You need to enter a valid Username & Password'; } else if (user_exists($username) === false ) { $errors[] = ' Sorry we could not find this user info in our userbase.'; } else if (user_active($username) === false ) { $errors[] = 'This account still needs to be activated'; } else { $login = login($username, $password); if ($login === false) { $errors[] = ' The Username / Password combination you entered is incorrect.'; } else { echo 'Login Ok!!'; Now finally my issue : When i click login all of my conditionals work except the most important one. When I input a working username and password i am given the same error from my array that the combination is not correct. so its finding the username but the password is not matching and accepting ? any suggestions ? i have been trying to figure this out for a minute. Thanks guys!. edit: (just wanted to add: sorry mods for all caps in title, tried to go back and edit but was to late)
  5. Im developing a site a that has login function, i have about 5 users with different user id. The problem is the code im using logs all the users as the first user in my database table, this means im essentially logged in as a another user. // function that gets users id from table users function user_id_from_username( $username ){ $username = sanitize( $username ); // do the query first $result = mysql_query( "SELECT user_id FROM users WHERE username = '$username'" )or die("Could not perform select query - " . mysql_error());;;; // if there was an error, or no results, $result will be FALSE. // if $result is not false, then you know there was a row returned $num_rows = mysql_num_rows($result); if($num_rows == 1) { return true; } else { return false; } } // function that checks the credentials and should return the correct user_id. function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = ($password); $query = mysql_query("SELECT COUNT(`user_id`) FROM guys WHERE username='$username' AND password='$password'"); return (mysql_result($query, 0) == 1) ? $user_id : false; } // finally logging the user and redirecting $login = login($username, $password); if ($login == false) { $errors[] = 'This username and password combination is incorrect'; }else { $_SESSION ['user_id'] = $login; header ('Location: index.php'); exit(); } function logged_in() { return (isset($_SESSION['user_id'])) ? true : false; } How can i log in the others users with the correct user id, and not just the first user ?
  6. Hey guys i have a project, Im wondering on how to approach it I have 5x5 table which is filled with data 1 day at a time. I need to save and retrieve the values everyday and show the same incomplete table to the user for 5 days. after 5 days i need to upload the values to DB. Uploading to DB isnt an issue. where/how to save data for each day and retrieve the values?
  7. Hi, I'm just wondering but if my webhost has SQL version 5.1, what are the syntax of that for PHP login & register forms? So like $q = "INSERT INTO `Table1` (`username`,`password`,`email`) " ."VALUES ('".$_POST["username"]."', " ."PASSWORD('".$_POST["password"]."'), " ."'".$_POST["email"]."')"; Would this be the right use of syntax? I'm having a few problems with making a clean and safe php login and register form. Thanks.
  8. suppose i've one starting data(1/12/2013) and final date (26/12/2013). What i want is that to update the database with the difference between the dates every day... means start data | Final Data | Days Left 1/12/2012 | 26/12/2012 | 25 <-------------- automatically done every day and updated in the database over writing the original values Means after 2 days it will show start data | Final Data | Days Left 1/12/2012 | 26/12/2012 | 23 Any help will be greately appreciated.....
  9. im trying to make a script where the user can update there details, (in this case the email) but when the script is running it comes up sucess to say its worked and updated. however when i open up my database in notepad or sql workbench the email has not changed its still the same. any ideas what it could be? or maybe im reading my database info wrong? CODE: <?php session_start(); $user_name = "root"; $password = ""; $database = "fixandrun"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); $currentemail = $_POST['currentemail']; $newemail = $_POST['newemail']; $confirmnew = $_POST['confirmemail']; $user = $_SESSION["username"]; if ($db_found) { $dbemail =mysql_query("SELECT email FROM staff WHERE username= '$user'"); //echo "$currentemail"; //echo "$newemail"; //echo "$confirmnew"; //echo "$dbemail"; if($currentemail == $dbemail || $newemail == $confirmnew) { $query = "UPDATE staff SET email = '$confirmnew' WHERE username = '$user'"; if(mysql_query($query)){ echo "updated";} else{ echo "fail";} } else { echo" some of your details are incorrect please try again. check that your current email is entered correctly and the new email matches."; } } else { print "Database NOT Found."; mysql_close($db_handle); } ?>
  10. hello every one... I want to have something similar like this in php that calculate the difference between dates ... date format = d/m/yyyy date1 = 8/5/13 date2 = 5/7/13 how to calculate the difference between the two dates in days.... Any help.....
  11. hello all of you. i have database name Products id pr_name good poor faulty i need auto complete search that they suggest (pr_name) from my phpmyadmin database. this is my search code: <div id="wb_Form2" style="position:absolute;width:483px;height:112px;"> <form name="search" method="get" action="db1.php" id="Form2" onsubmit="return Validatesearch(this)"> <input type="text" id="Editbox8" style="position:absolute;left:11px;top:17px;width:456px;height:38px;line-height:38px;z-index:2;" name="query" value="" autocomplete="off" input type="text" name="query"> <input type="submit" id="Button3" name="" value="Add" style="position:absolute;left:192px;top:71px;width:96px;height:37px;z-index:3;"> </form> </div> and this is my search code: <html> <body> <head> <font size="3"><strong> <?php // Connects to your Database mysql_connect("host", "user", "pass") or die(mysql_error()); mysql_select_db("table") or die(mysql_error()); $q = mysql_real_escape_string($_GET['query']); $data = mysql_query("SELECT * FROM Products where name LIKE '%$q%'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo "Product Name: $info[name]<br>"; echo "Good Price: $info[good]<br>"; echo "Poor Price: $info[poor]<br>"; echo "Faculty Price: $info[faulty]<br><br>"; } ?>
  12. Guys, I'm a newbie. There, I got that out of the way.... I have a form that can be submitted and then modified. The data gets sent to a mySQL db. It's nothing special. The idea is that the user is to click a checkbox located at the bottom of the form that says "I'm finished with my project" when checked the stored value is "yes". Everything works fine the value gets stored and all is well except I can not get the darn thing to echo the chekced value. Below is what I have tried with no joy. <input type="checkbox" name="projectcomplete[]" <?php if ($user_type_detail["projectcomplete"]=='Yes') {echo "checked";} ?>> Why the heck won't it work? The value "yes" is stored. Arrrggggg.... I also tried isset with no joy... <input type="checkbox" name="projectcomplete" <?php if (isset($yes)) { echo 'value="checked"'; }?> > The following code below works perfectly on the form. I have refferenced it but no solution materialized. What can I tell ya.. I'm a newb... I don't have the skills to uncover the solution. input type="radio" class="radio" name="CYSD_Particiapant" value="Yes" <?php if($user_type_detail["CYSD_Particiapant"]=='Yes') echo 'checked=checked';else echo '';?> />Yes<input class="radio" type="radio" name="CYSD_Particiapant" value="No" <?php if($user_type_detail["CYSD_Particiapant"]=='No') echo 'checked=checked';else echo '';?> />No Any help would be very much appriated.
  13. I am working through a Create a CMS tutorial and I am on the very last step, but I am hung up. My code is below. It is supposed to pull up a blank form when you want to add a new blog post and it is supposed to populate the field when you want to edit a previous blog post. That all works fine. The edit a blog post functionality works as it should. My problem is when I submit a new blog post, the data does not get sent to the database. Any ideas where I may have gone wrong? Aaron <?php ## Blog Manager?> <?php if (isset($_POST['submitted']) == 1) { if ($_GET['id'] == '') { $q = "INSERT INTO blog (title, date, body) VALUES ('$_POST[title]', '$_POST[date]', '$_POST[body]'"; }else { $q = "UPDATE blog SET title = '$_POST[title]', date = '$_POST[date]', body = '$_POST[body]' WHERE id = '$_POST[id]'"; } $r = mysqli_query($dbc, $q); } ?> <h2>ATOM.CMS Blog Manager</h2> <div class="col sidebar"> <ul class="nav_side"> <li><a href="?page=blog">+ Add Post</a></li> <?php $q = "SELECT * FROM blog ORDER BY date ASC"; $r = mysqli_query($dbc, $q); if ($r) { while ($link = mysqli_fetch_assoc($r)) { echo '<li><a href="?page=blog&id='.$link['id'].'">'.$link['title'].'</a></li>'; } } ?> </ul> </div> <div class="col editor"> <h1> <?php if (isset($_GET['id'])) { $q = "SELECT * FROM blog WHERE id = '$_GET[id]' LIMIT 1"; $r = mysqli_query($dbc, $q); $opened = mysqli_fetch_assoc($r); echo 'Editing: '.$opened['title']; } else { echo 'Add a New Blog Post'; } ?> </h1> <form action="?page=blog&id=<?php if (isset($_GET['id'])){echo $opened['id'];} ?>" method="post"> <table class="gen_form"> <tr> <td class="gen_label"><label>Blog title: </label></td> <td><input class="gen_input" type="text" size="30" name="title" value="<?php if (isset($_GET['id'])){echo $opened['title'];} ?>" /></td> </tr> <tr> <td class="gen_label"><label>Blog date: </label></td> <td><input class="gen_input" type="text" size="30" name="date" value="<?php if (isset($_GET['id'])){echo $opened['date'];} ?>"/></td> </tr> <tr> <td class="gen_label"></td> </tr> <tr> <td colspan="2" class="gen_label"><label>Blog body: </label></td> </tr> <tr> <td colspan="2"><textarea id="page_body" name="body" cols="90" rows="24"><?php if (isset($_GET['id'])){echo $opened['body'];} ?></textarea></td> </tr> <tr> <td colspan="2"><input class="gen_submit" type="submit" name="submit" value="Save Changes" /></td> </tr> <input type="hidden" name="submitted" value="1" /> <input type="hidden" name="id" value="<?php if (isset($_GET['id'])){echo $opened['id'];} ?>" /> </table> </form> </div>
  14. I'm trying to include a checkbox group in a form submission. The user can check one, two, or all three of the choices. I need only the checked boxes to how can i do that? help me with a small example if possible so that i can nderstand well,plzzz. Thank you!
  15. Hey, Im new to PHP and am trying to make a simple form where it puts the form data into a table called "users" This is the form: <p><form method="post" action="register.php"> <table border="0" align="center"> <tr> <td>Username</td><td><input type="text" name="username" size="15" > </tr> <br /> <tr> <td>Password</td><td><input name="password" type="password" size="15"></td> </tr> <br /> <td><input type="submit" value="Sign Up"/></td><td></td> </table> This is the php code: <?php $dbhost = ''; $dbname = ''; $dbuser = ''; $dbpass = ''; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname); $order = "INSERT INTO users (username, password) VALUES ('$username', '$password')"; $result = mysql_query($order); if($result){ echo("<br>It Worked!"); } else{ echo("<br>It Failed!"); } ?> But when i upload it to the server and try it, it says there was a entry but its blank..... When i upload it to a server and try it, it automaticly seems to post the data to the database before i even enter a username/password! when i type a username/password in and post it again it says there was another entry but its blank..... any help? - Thanks!
  16. What it is doing: Right now it is taking the last known team members ($allteammembers) on all the rest of the results that do not have any team members. - So it should show nothing. What I want it to do: To show nothing for $allteammembers when there is no data found. - Like the way I think I have it coded. The Full Code Going Through Database: if ($stmt = $mysqli->prepare("SELECT title, caption, category, image, placement, teammember1, teammember2, teammember3, otherpeople, downloads, views FROM photogallery WHERE year = ? AND timeofday = ? AND status = 1 ORDER BY category, placement")) { $stmt->bind_param('is', $year, $timeofday); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($title, $caption, $category, $image, $placement, $teammember1, $teammember2, $teammember3, $otherpeople, $downloads, $views); while($stmt->fetch()) { if ((!empty($placement))) { $stmt2 = $mysqli->prepare("SELECT boat, teammember1, teammember2, teammember3, channel, flathead, blue, total, bigfish, totalweight FROM tourneyresults WHERE year = ? AND timeofday = ? AND placement = ?"); $stmt2->bind_param('isi', $year, $timeofday, $placement); $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($boat, $member1, $member2, $member3, $channels, $flatheads, $blue, $total, $bigfish, $weight); $stmt2->fetch(); $stmt2->close(); $link1 = addplus($member1); $link2 = addplus($member2); $link3 = addplus($member3); if ((!empty($member1)) && (!empty($link1))) {$member1 = "<a href='$mainurl/fisher/$link1'>$member1</a>";} if ((!empty($member2)) && (!empty($link2))) {$member2 = "and <a href='$mainurl/fisher/$link2'>$member2</a>";} if ((!empty($member3)) && (!empty($link3))) {$member3 = "and <a href='$mainurl/fisher/$link3'>$member3</a>";} if ($boat) {$boat2 = "~ Boat #$boat";} else {$boat2 = "";} if ($channels) {$channels2 = "$channels Channel(s)";} else {$channels2 = "";} if ($flatheads) {$flatheads2 = " | $flatheads Flathead(s)";} else {$flatheads2 = "";} if ($blue) {$blue2 = " | $blue Blue(s)";} else {$blue2 = "";} if ((!empty($member1)) && (!empty($link1))) {$allteammembers = "<b>Team Members: </b>$member1 $member2 $member3 $boat2<br><span style=\"padding-left: 20px\">Caught: $channels2$flatheads2$blue2</span><br><br>";} else {$allteammembers = "";} } $link5 = addplus($teammember1); $link6 = addplus($teammember2); $link7 = addplus($teammember3); if ((!empty($teammember1)) && (!empty($link5))) {$teammember1 = "<a href='$mainurl/fisher/$link5'>$teammember1</a>";} if (!empty($teammember2) && !empty($link6)) {$teammember2 = "and <a href='$mainurl/fisher/$link6'>$teammember2</a>";} if (!empty($teammember3) && !empty($link7)) {$teammember3 = "and <a href='$mainurl/fisher/$link7'>$teammember3</a>";} if ((!empty($teammember1)) && (!empty($link5))) {$teammemberspictured = "<b>Team Members Pictured: </b>$teammember1 $teammember2 $teammember3<br>";} else {$teammemberspictured = "";} if ((!empty($otherpeople)) && (((!empty($teammember1)) && (!empty($link5))) || ((!empty($member1)) && (!empty($link1))))) {$otherpeople2 = "<b>Other People in This Photo:</b> $otherpeople<br>";} if (!empty($otherpeople) && ((empty($teammember1)) && (empty($link5))) && ((empty($member1)) && (empty($link1)))) {$otherpeople2 = "<b>People in This Photo:</b> $otherpeople<br>";} if (($category == "0") || (empty($category))) {$category2 = "No Category";} if (($category == "1")) {$category2 = "First Place Winner";} if (($category == "2")) {$category2 = "2nd-5th Place Winners";} if (($category == "3")) {$category2 = "6th-12th Place Winners";} if (($category == "4")) {$category2 = "13th-20th Place Winners";} if (($category == "5")) {$category2 = "13th-24th Place Winners";} if (($category == "6")) {$category2 = "Big Fish Winners";} if (($category == "7")) {$category2 = "Take Off";} if (($category == "8")) {$category2 = "Weigh In";} if (($category == "9")) {$category2 = "Scoreboard";} if (($category == "10")) {$category2 = "Prizes from Drawing";} if (($category == "11")) {$category2 = "Kids Prizes and Face Painting";} if (($category == "12")) {$category2 = "Morning Meeting";} if (($category == "13")) {$category2 = "Sign Up";} if (($category == "14")) {$category2 = "Spectators";} if (($category == "15")) {$category2 = "Misc.";} if (($category == "16")) {$category2 = "Extra Photos";} if ($timeofday == "night") {$subfolder = "NightTourney";} else {$subfolder = "year";} ECHO<<<END <div class="gallery" id="container"> <div id="left"> <img src="$mainurl/images/$subfolder/$year/$image"> </div> <div id="bottom"> $category2 | <a href="$mainurl/images/year/$year/$image" class='links'>Download Image</a> | $downloads downloads | $views views | Report Error | Add A Comment </div> <div id="right"> <h3>$title</h3> $allteammembers $teammemberspictured $otherpeople2 <p>$caption</p> </div> </div> END; } $stmt->close(); } Snippet Not Working Correctly: if ((!empty($member1)) && (!empty($link1))) {$allteammembers = "<b>Team Members: </b>$member1 $member2 $member3 $boat2<br><span style=\"padding-left: 20px\">Caught: $channels2$flatheads2$blue2</span><br><br>";} else {$allteammembers = "";} I would like to know how to fix it and why it is doing it exactly? All my ideas failed. :/
  17. I have a database of chemicals. Some of the chemicals are drugs while others are solvents and different types of chemicals. For the drugs, I need to add a pharmacology field and a medicinal properties field but the other types of chemicals don't need this field. The other types of chemicals will need their own special fields too. Should I just add all these fields to the same table or is there a better way of doing it? For example, would it be better if I added a seperate table that holds all these special information fields?
  18. i have created a registration form page with id,name,col,branch,etc Coming to the database ID is primary and auto increment, im trying to print the generated value of from the database after the registration is done. For example: "You have Successfully registered with us n your id is xxxxxx" Please someone helpme out with this
  19. Hello, I am working on a personal project which is to generate a set of unique codes and store them in a database. The concept of the project is for me to be able to determine the numbers of codes I want to generate and insert each of them into the database. I have been able to come up with something with the help of a tutorial which is working but not inputting into database and it allows one generation at a time. Please see my code below $username = "root"; $password = "password"; $hostname = "localhost"; $database = "gencode"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db($database,$dbhandle) or die("Could not select $database"); $unique_ref_length = 11; $unique_ref_found = false; $possible_chars = "23456789ABCDFGHJKLMNPQRSTWXYZ"; while (!$unique_ref_found) { $unique_ref = ""; $i = 0; while ($i < $unique_ref_length) { $char = substr($possible_chars, mt_rand(0, strlen($possible_chars)-1), 1); $unique_ref .= $char; $i++; } $query = "SELECT `order_ref_no` FROM `orders` WHERE `order_ref_no`='".$unique_ref."'"; $result = mysql_query($query) or die(mysql_error().' '.$query); if (mysql_num_rows($result)==0) { $unique_ref_found = true; } } echo 'Our unique reference number is: '.$unique_ref; Your assistance will be greatly appreciated.
  20. Hi, I'm rookie in php checkbox and I'm trying to understand how to write the code , i have five checkbox in one form like this <form action="" method="get"><input name="one" type="checkbox" value="one" /> one<br /> <input name="two" type="checkbox" value="two" /> two<br /> <input name="three" type="checkbox" value="three" /> three<br /> <input name="four" type="checkbox" value="four" /> three<br /> <input name="five" type="checkbox" value="five" /> three<br /> </form> if checkbox on then show the box, if checkbox is not check, then not show the box, so i understand that need to use zero or one in mysql database in one column called "display". My question is that how can i write the code in checkbox form whether if is zero or one, but how to write code to show DISPLAY OR NOT DISPLAY when reatrieve from mysql database EVEN USING CSS OR NOT. please help thanks. AM
  21. I have stored a image in database as it is small dd not upload in folder it got uploade and is shown in database i stored it with using $imgData =addslashes (file_get_contents($_FILES['image']['tmp_name'])); then a insert query with $imgData Now when i retrive it with select query from database and display <td rowspan="12"><?php header('Content-type:image/jpg'); $img=stripslashes($info['image']); echo $img; ?></td> it shows The image "localhost/final/../f.php?action="view&id=53" cannot be displayed because it contains errors
  22. I have a data base that updates the photo 1) A error occurs everytime i update the database error:- Error in 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 '\0JFIF\0\0`\0`\0\0ÿÛ\0C\0 ' at line 3 code:- $sql = "UPDATE freelancer SET image=$imgData, name='{$_FILES['image']['name']} WHERE id=$in"; here $imgData is image with slashes 2) this is the error for Error in 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 ''image-04.jpg WHERE id=29' at line 3 code:- $sql = "UPDATE freelancer SET image='$imgData', name='{$_FILES['image']['name']} WHERE id=$in"; please help for the error
  23. MYSQL version: 5.5.27-cll - MySQL Community Server (GPL) Hey I have a simple articles and comments table. I want to display the articles along with their comments. I want to union with one select with the comments and another select without the comments on the same table. I have article number 1 with 1 comment and article number 2 with no comments and article number 3 with 2. I use the following query to get the results. SELECT articles.id AS article_id, comments.id AS comment_id, comment FROM articles LEFT JOIN comments ON comments.aid = articles.id UNION ALL SELECT articles.id AS article_id, NULL, NULL FROM articles GROUP BY article_id ORDER BY article_id DESC The result I get which is correct: article_id | comment_id | comment 3 | 3 | good 3 | 2 | very good 3 | NULL | NULL 2 | NULL | NULL 2 | NULL | NULL 1 | NULL | NULL 1 | 1 | | bad one Now if I want to count the comments also I add COUNT to the query and it becomes: SELECT articles.id AS article_id, comments.id AS comment_id, comment , COUNT(DISTINCT comments.id) AS count_comments FROM articles LEFT JOIN comments ON comments.aid = articles.id UNION ALL SELECT articles.id AS article_id, NULL, NULL , NULL FROM articles GROUP BY article_id ORDER BY article_id DESC Now the results change after adding the the count column and not all rows are outputted: article_id | comment_id | comment 3 | NULL | NULL 2 | NULL | NULL 1 | NULL | NULL 1 | 1 | bad one Now the comments aren't displayed except the comment of article 1, ID(2) should be displayed twice for the 2 select commands, and ID(3) should be displayed 3 times (1 for the second select command and 2 for the first select commands as there are 2 comments) I don't know why adding count leads to ths. Thanks
  24. Hello, I have founde this tutorial: http://www.hdeya.com/blog/2009/05/sorting-items-on-the-fly-ajax-using-jquery-ui-sortable-php-mysql/comment-page-1/#comment-865 I tried to do it, but I can't get the setup of my database to work as you can see here: http://www.danieldoktor.dk/jQuery%20UI%20Sortable%2C%20PHP%20%26%20MySQL/menu_list.php My domain is hosted by www.one.com, so I know it is possible, and I have installed wordpress on my server too. Can someone help Daniel
  25. Hey I have a simple articles table with IDs. I want to get the highest and lowest ids from the latest 10 results. For example, if there are 11 ids, the result should be 2 and 11 and if there are 4 ids, should be 4 and 1 and so on. I use PHP PDO statements. $aid = $DBH->prepare("SELECT id FROM articles ORDER BY id DESC LIMIT 10"); $aid->execute(); $row = $aid->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_LAST); $lowest_article_id = $row[0]; $row = $aid->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_FIRST); $highest_article_id = $row[0]; The above will always return 11 if there are 11 records and 10 if there are 10 records. So, the query ignores the PDO::FETCH_ORI_LAST and PDO::FETCH_ORI_FIRST part of the query. Thanks
×
×
  • 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.