Jump to content

Search the Community

Showing results for tags 'sql'.

  • 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. Query: SELECT UMTS_napetude_cell.parent, UMTS_napetude_nodeb.idnap FROM UMTS_napetude_cell LEFT JOIN UMTS_napetude_nodeb ON UMTS_napetude_cell.parent IS NOT LIKE CONCAT('%',UMTS_napetude_nodeb.idnap,'%') WHERE UMTS_napetude_cell.parent IS NOT NULL Error: Thanks in advanced.
  2. I have been tasked to find the problem with this site's database connection. The site is a PHP, MySQL, Smarty site. Currently, I am getting the following when www.mysite.com is called. The index.php is located at www.mysite.com/index.php The current locations of the following files are: includes/ru_config.com includes/ru_connection.com All the replaced passwords, usernames, and site specific information worked previously so the problem is not there. One problem there might be, is in ru_connection where the paths for ru_4pear and DB.php might be wrong. There locations are: includes/ru_4pear.com libs/pear/DB.php ru_config.php index.php ru_connection.php DB.php ru_4pear.php
  3. I would like to solve this query. Query: $sql = 'SELECT DISTINCT *, c.ci as c_i FROM `GSM_cellule` c '. 'LEFT JOIN '.$table_freq.' f ON(c.nidtint=f.nidtint) '. 'WHERE c.NAP_'.$site->ur().' =\'1\' '. $this->_in.' and '.$this->_inetatbdespec.' and '.$this->_inindus.' GROUP BY c.nidtint ORDER BY c.nidtint '; Error: Thanks in advanced.
  4. Hey all. First I want to say that I'm very amateur when it comes to coding. Most of what I know has been self-taught so I don't have any formal education. My coding vocabulary is awful, but generally when I build code I understand what it's doing in laymen terms (ex. it's pulling data from the "users" row in a table and is displaying that data). Anyway...that's my disclaimer to ask you to be easy on me. So now to my actual issue. I've built a page where logged in users can share photos with their friends. I successfully built this without any issues. Now I want friends to be able to add comments to the photos. Not so easy. Problem is I have two tables built. One for the sharing of the photos the other for the comments. Here are how the tables are built out: Photo Table id | username | initiator | file | gallery | date_time Comment Table id | comment | user | file | date_time Initially I had two queries. Both use a "fetch" array in order to grab and then display specific info in a specific order only for specific users. This was almost working but whichever query came first would only display one result. The query that came after would display all the appropriate results which is what I wanted out of both queries. On another forum I was told that I needed to "join" or "union" the two queries together. Problem is that when I attempt to do that I get a single dead image, no comments other than the default stuff that is already entered in the PHP code and the error: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given... Here is the actual query and code: //WHERE I GATHER COMMENT & PHOTO DATA $sql = "SELECT comment, user, file, date_time FROM comment UNION ALL SELECT DISTINCT initiator, file, gallery FROM photo WHERE username='$log_username' OR initiator='$log_username' ORDER BY date_time DESC"; $query = mysqli_query($db_conx, $sql); while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $c = $row["comment"]; $us = $row["user"]; $pf = $row["file"]; $time = $row["date_time"]; $u = $row["initiator"]; $file = $row["file"]; $gallery = $row["gallery"]; $image = 'user/'.$u.'/'.$file; } //WHERE I DISPLAY THE PHOTO DATA $imagelist .= ' <img height="200" onclick="this.height=500;" ondblclick="this.height=200;" src="'.$image.'" alt="'.$u.'" /><br /> Added to <a href="user.php?u='.$u.'"><b>'.$u.''s</b></a> '.$gallery.' gallery<br /><br /> <form action="php_parsers/photocomments_system.php" enctype="multipart/form-data" method="post"> <input type="text" name="comment"> <input type="hidden" name="photo_file" value="'.$file.'"> <input type="submit" class="submit" value=" Submit Comment " /> </form><br /><p style="border-bottom: 1px dotted #A0A0A0;"></p>'; //WHERE I DISPLAY THE PHOTO COMMENTS AND DICTATE WHAT COMMENT SHOWS WITH WHAT PHOTO if ($pf == $file) { $imagelist .='<p style="background-color:#E0E0E0;"> <b>'.$us.'</b>: '.$c.' | '.$time.'</p> <br /><br /><hr/>'; } For the HTML portion this is where it actually gets displayed: <div id="page Middle"><?php echo $imagelist; ?></div> Anyway, I'm assuming there is something wrong with my query and that's why I'm getting the error. Problem is I'm not sure what is wrong with the query. If there is any easier way to do this and I was doing something wrong with the two separate queries that could easily be resolved I can show you how I built that as well. I would continue on the other forum with the guy that was helping me but he was a little bit too technical for me to understand his suggestions. Anyway, any help you could give would be GREATLY appreciated. Thanks!
  5. This query is not working. I need urgent help. Thanks a lot in adv. ROWS affected: 0 I have cross checked the data in the table for the given condition. $sql = 'UPDATE LTE_noria_cellule cel_bk_up SET cel.NAP_'.$site->ur().' = \'1\' '. 'WHERE cel.nidt IN ( select gn from LTE_noria_candidat_bk_up can INNER JOIN LTE_noria_site_bk_up site ON (site.codesite = can.codesite) WHERE '.$site->get_param('zone_bde').')'; I believe problem is because of WHITESPACE. When i search "codesite" in the table with "LIKE". I can't find it. But when i did "LIKE%" , it's working. I tried this also but not working $sql = 'UPDATE LTE_noria_cellule cel_bk_up SET cel.NAP_'.$site->ur().' = \'1\' '. 'WHERE cel.nidt IN ( select gn from LTE_noria_candidat_bk_up can INNER JOIN LTE_noria_site_bk_up site ON trim(site.codesite) LIKE CONCAT('%',trim(can.codesite),'%') WHERE '.$site->get_param('zone_bde').')';
  6. When trying to upload a picture file it goes error:Failed to upload file. Contact Site admin to fix the problem What am I doing wrong ======================= <?php include 'db.php'; $id=@$_GET['id']; $ya=mysql_query("select * from `registeronline` where user_id='$id'"); $yb=mysql_fetch_array($data); $val= '$id'+2400241106; if (!isset($_POST["Submit"])) { echo ""; }else{ $file=@$_POST['pix']; if (isset($HTTP_POST_FILES["pix"])){ $upload_type =$HTTP_POST_FILES["pix"]["type"]; $upload_name=$HTTP_POST_FILES["pix"]["name"]; $upload_size=$HTTP_POST_FILES["pix"]["size"]; $upload_tmp_name=$HTTP_POST_FILES["pix"]["tmp_name"]; } else { echo "" ; } if ($userfile_size >250000){$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size and then upload. Visit the help page to know how to reduce the file size.<BR>"; $file_upload="false";} if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>"; $file_upload="false";} $add="upload/$userfile_name"; // the path with the file name where the file will be stored, upload is the directory name. if(move_uploaded_file ($userfile, $add)){ // Your Picture has been uploaded successfully. }else{echo "Failed to upload file. Contact Site admin to fix the problem";} $z=mysql_query("update `registeronline` set pix='$file' where `user_id`='$id' "); if (!$z ) { echo "<script>alert('Update Not Successful')</script>"; }else{ } }
  7. Hey, so to display an image from a database I was using $id = addslashes($_REQUEST['id']); $image = mysql_query("SELECT * FROM store_image WHERE id=$id"); $image = mysql_fetch_assoc($image); $image = $image['image']; header("Content-type: image/jpeg"); echo $image; That worked fine to return an image via matching the id. But I want to get ALL images from the table.. I tried this: $image = mysql_query("SELECT * FROM store_image"); while($image = mysql_fetch_array($image)){ $image = $image['image']; header("Content-type: image/jpeg"); echo $image; } But did not work.. what am I doing wrong?
  8. Hello guys, I posted this Question in MYSQL thread accidentally, so I'll try to ask the same here since I use Oracle RDBMS. Need help regarding SQL and aggregate function. I would like to do max function (or some join or something else), to get max value of column, and other column with it also. Here's the code: SQL> select department_id, sum(salary) place_total from employees where department_id is not null group by department_id; Previous query outputs this: DEPARTMENT_ID PLACE_TOTAL ------------- ----------- 90 58000 20 19000 110 20300 50 17500 80 30100 60 19200 10 4400 Now, how to edit previous sql statement so it can output department_id, and max(place_total), so the output result is: DEPARTMENT_ID PLACE_TOTAL ------------- ----------- 90 58000 Anyone have an idea, how to do this ? Thanks !
  9. I have found some code that I am trying to work with to import some data from a CSV file into a table of my database. It works and imports the data, but always inserts a NULL row for each column. Here is the code: <?php $self = $_SERVER['PHP_SELF']; $request = $_SERVER['REQUEST_METHOD']; if (!isset($_GET['success'])) { $get_success = ""; } else { $get_success = $_GET['success']; } if (!empty($_FILES)) { /* Format the errors and die */ function get_last_error() { $retErrors = sqlsrv_errors(SQLSRV_ERR_ALL); $errorMessage = 'No errors found'; if ($retErrors != null) { $errorMessage = ''; foreach ($retErrors as $arrError) { $errorMessage .= "SQLState: ".$arrError['SQLSTATE']."<br>\n"; $errorMessage .= "Error Code: ".$arrError['code']."<br>\n"; $errorMessage .= "Message: ".$arrError['message']."<br>\n"; } } die ($errorMessage); } /* connect */ function connect() { if (!function_exists('sqlsrv_num_rows')) { // Insure sqlsrv_1.1 is loaded. die ('sqlsrv_1.1 is not available'); } /* Log all Errors */ sqlsrv_configure("WarningsReturnAsErrors", TRUE); // BE SURE TO NOT ERROR ON A WARNING sqlsrv_configure("LogSubsystems", SQLSRV_LOG_SYSTEM_ALL); sqlsrv_configure("LogSeverity", SQLSRV_LOG_SEVERITY_ALL); $conn = sqlsrv_connect('cslogs', array ( 'UID' => 'mailreport', 'PWD' => '123456', 'Database' => 'Mail', 'CharacterSet' => 'UTF-8', 'MultipleActiveResultSets' => true, 'ConnectionPooling' => true, 'ReturnDatesAsStrings' => true, )); if ($conn === FALSE) { get_last_error(); } return $conn; } function query($conn, $query) { $result = sqlsrv_query($conn, $query); if ($result === FALSE) { get_last_error(); } return $result; } /* Prepare a reusable query (prepare/execute) */ function prepare ( $conn, $query, $params ) { $result = sqlsrv_prepare($conn, $query, $params); if ($result === FALSE) { get_last_error(); } return $result; } /* do the deed. once prepared, execute can be called multiple times getting different values from the variable references. */ function execute ( $stmt ) { $result = sqlsrv_execute($stmt); if ($result === FALSE) { get_last_error(); } return $result; } function fetch_array($query) { $result = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC); if ($result === FALSE) { get_last_error(); } return $result; } $conn = connect(); /* prepare the statement */ $query = "INSERT Records values ( ? , ? , ? )"; $param1 = null; // this will hold col1 from the CSV $param2 = null; // this will hold col2 from the CSV $param3 = null; // this will hold col3 from the CSV $params = array( $param1, $param2, $param3 ); $prep = prepare ( $conn, $query, $params ); $result = execute ( $prep ); //get the csv file $file = $_FILES["csv"]["tmp_name"]; /* Here is where you read in and parse your CSV file into an array. That may get too large, so you would have to read smaller chunks of rows. */ $csv_array = file($file); foreach ($csv_array as $row_num => $row) { $row = trim ($row); $column = explode ( ',' , $row ); $param1 = $column[0]; $param2 = $column[1]; $param3 = $column[2]; // insert the row $result = execute ( $prep ); } /* Free statement and connection resources. */ sqlsrv_close($conn); header( "Location: test.php?success=1" ); } ?> <!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>Import a CSV File with PHP & MS SQL Server</title> </head> <body> <?php if (!empty($get_success)) { echo "<b>Your file has been imported.</b><br><br>"; } //generic success notice ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> Choose your file: <br /> <input name="csv" type="file" id="csv" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> Now I know it is at this part wiht the $param1, $param2 and $param 3 that it is inserting the NULL values for each column: /* prepare the statement */ $query = "INSERT Records values ( ? , ? , ? )"; $param1 = null; // this will hold col1 from the CSV $param2 = null; // this will hold col2 from the CSV $param3 = null; // this will hold col3 from the CSV $params = array( $param1, $param2, $param3 ); $prep = prepare ( $conn, $query, $params ); $result = execute ( $prep ); But if I take that out them three out, the php errors out then doesn't import the data. Is there a way with what I have to ignore the first row to import? Or am I going about this all wrong?
  10. Update is not working.. UPDATE Customers SET ContactName='Alfred Schmidt', City='Hamburg' WHERE CustomerFirstName='Alfreds' AND CustomerLastName='Futterkiste' Thanks in advanced.
  11. I am having trouble getting a simple form to submit data to a database. I have followed an example in a PHP/MySQL book (Welling and Thomson) and created a simple form to update a DVD collection. Right now I just have a form started and am just trying to get it to INSERT records into my database. It is making a connection to the database, but it returns my Error stating that the record could not be added. While all of my code is very basic,I am just trying to get an understanding as to how it is working... I have looked in MySQL through command prompt and the database exists, but records are not being added. I can add records to the table through CMD prompt. I will post my code for the database and my two php files for inserting records. Database: create database movie_info; use movie_info; create table movies (movieid int unsigned not null auto_increment primary key, title char(50) not null, movieyear char(4) not null, genre char(25) not null, subgenre char(25), director char(30), actor1 char(30), actor2 char(30), actor3 char(30), discs char(2), season char(2), comments char(200) ); Form: function input_form(){ ?> <form method="post" action="insert_movie.php"> <table bgcolor="#cccccc"> <tr> <td colspan="2">Enter a new DVD:</td> <tr> <td>Title:</td> <td><input type="text" name="title"/></td></tr> <tr> <td>Year:</td> <td><input type="text" name="year"/></td></tr> <tr> <tr> <td>Genre:</td> <td><input type="text" name="genre"/></td></tr> <tr> <tr> <td>Sub-Genre:</td> <td><input type="text" name="subgenre"/></td></tr> <tr> <tr> <td>Director:</td> <td><input type="text" name="director"/></td></tr> <tr> <tr> <td>Actor:</td> <td><input type="text" name="actor1"/></td></tr> <tr> <tr> <td>Actor:</td> <td><input type="text" name="actor2"/></td></tr> <tr> <tr> <td>Actor:</td> <td><input type="text" name="actor3"/></td></tr> <tr> <tr> <td>Number of discs:</td> <td><input type="text" name="discs"/></td></tr> <tr> <tr> <td>Season:</td> <td><input type="text" name="season"/></td></tr> <tr> <tr> <td>Comments:</td> <td><input type="text" name="comments"/></td></tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Submit"/></td></tr> <tr> </table></form> <?php } and the INSERT code: <?php require_once('movie_functions.php'); //require_once('db_functions.php'); do_html_header('Moviebase'); @$title = $_POST['title']; @$year = $_POST['year']; @$genre = $_POST['genre']; @$subgenre = $_POST['subgenre']; @$director = $_POST['director']; @$actor1 = $_POST['actor1']; @$actor2 = $_POST['actor2']; @$actor3 = $_POST['actor3']; @$discs = $_POST['discs']; @$season = $_POST['season']; @$comments = $_POST['comments']; if (!$title || !$year || !$genre) { echo "You have not entered all of the required details. <br />" ."Please go back and try again.<br /><br />" ."<a href='movies.php'>Go Back</a>"; exit; } @$db = new mysqli('localhost', 'root', '********', 'movie_info'); if (mysqli_connect_errno()) { echo "Error: Could not connect to database. Please try again later."; exit; } $query = "INSERT INTO movies VALUES (NULL, '".$title."', '".$year."', '".$genre."', '".$subgenre."', '".$director."', '".$actor1."', '".$actor2."', '".$actor3."', '".$discs."', '".$season."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." has been inserted into the database."; //input_form(); } else { echo "An error has occurred. The item was not added."; //for testing echo "<br />Result: ".$result; echo "<br />".$title; echo "<br />".$year; echo "<br />".$genre; echo "<br />".$subgenre; echo "<br />".$director; echo "<br />".$actor1; echo "<br />".$actor2; echo "<br />".$actor3; echo "<br />".$discs; echo "<br />".$season; echo "<br />".$comments; //input_form(); } $db->close(); footer(); ?> This all will return all variable values (except $result), so it seems like $result is empty. Any help in understanding this would be greatly appreciated, Thanks!
  12. I wonder if anyone can help me. I'm creating an application in PHP and am using a SQL server database on my local computer to develop the application. The only problem is I cannot connect to the database. My code looks like <?php $serverName = "LIAMJAY-PC\SQLEXPRESS"; //serverName\instanceName $connectionInfo = array( "Database"=>"ONEDB"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.<br />"; }else{ echo "Connection could not be established.<br />"; die( print_r( sqlsrv_errors(), true)); } ?> to connect to the database. However, everytime I run the code I keep getting a 18456 error code. Does anybody know what my problem is and if so, what is the solution???
  13. Hi guys, I'm kinda new to PHP, and I started with developing a site. Now I've a piece of code (check below), it is suppost to edit a page in the database, but the output is "Error updating database1: Unknown column 'title' in 'field list'". But, the column exist! All variables are set, and I don't know what I'm doing wrong, and I hope you guys can help me. Code: $query_update = "UPDATE `pagina` SET `title` = '".addslashes($title)."', `korting`='".$korting."', `volg`='".$volg."', `product` = '".$product."',`product_id`='".$product_id."', `visible` = '".$visible."', `metadescription` = '".addslashes($metadescription)."', `url` = '".$url."', `content` = '".addslashes($content)."', `headerpicture`='".addslashes($headerpicture)."',`picture`='".addslashes($picture)."', form_id = '".$form_id."',`related`='".$related_string."', `datum` = NOW() WHERE `id` = '".$id."'"; mysql_query($query_update)or die('Error updating database1: '.mysql_error()); Column: Greetzz iRoot121.
  14. I have an SQL query that inserts data into my database. I'm trying to use the mysql function STDDEV_SAMP(), and it doesn't appear to work. Here it is: $query = "INSERT INTO table (percent, deviation) VALUES ($percent, STDDEV_SAMP(percent))"; I've searched around to see if anyone has used Aggregate functions in an INSERT INTO query, but I haven't found anything that has helped me yet. Note that this is sample code that I'm using to display my problem.
  15. My table 'guess': id (int) | user_id (int) | logo_id (int) | guess (varchar) | guess_count (int) | guessed (int) id is unique, unique relation between user_id & logo_id When a user visits the site, a user is made in a 'users' table (so there's a new user_id). The user can then play with this user_id. When the user logs in, the current scores/guesses/... should be transferred to the user_id of the logged in-account. How do I get this done? To clarify: there are two user_id's in play - the user_id from the registered (logged in) user, and the user_id from the session (not logged in). I will refer to these as user_id_login and user_id_session. So, if a row of user_id_login has a guessed = 1 (this int is 0/1. 1 means guessed, 0 means not guessed) for certain logo_id, a row with that logo_id and the user_id_session should be completely ignored. If a row of user_id_login = 0 for certain logo_id exists, the values 'guess_count', 'guessed' and 'guess' of the row with the same logo_id and with user_id_session should be added (for guess_count) or stored (guessed & guess). If a row with user_id_session for certain logo_id exists and hasn't been checked in one of the previous, the user_id of this should be changed from user_id_session to user_id_login. Now how I currently would think about doing this, is check the table for the user_id_login where guessed = 1. For each result, then do a query to check if there is a user_id_session with that logo_id and remove them. Next, check the table for the user_id_login with guessed = 0. For each result, then check if there is a user_id_session with the same logo_id and add those values, then delete that row. And at last, a query to check all the leftover user_id_session and change the id to user_id_login. As you can see, this is dozens of query's, so there must be a better way
  16. SELECT verifierId, email, notes, docId, CASE WHEN tot0 = totdocs THEN 'Pending' WHEN tot1 = totdocs THEN 'Approved' WHEN tot2 = totdocs THEN 'Declined' WHEN tot3 = totdocs THEN 'Incomplete' ELSE 'Ongoing' END as status FROM ( SELECT v.verifierId, v.email , v.notes, d.docId, SUM(IF(f.fileStatus=2,1,2)) as tot2, SUM(IF(f.fileStatus=0,1,0)) as tot0, SUM(IF(f.fileStatus=1,1,0)) as tot1, SUM(IF(f.fileStatus=0,2,1)) as tot3, COUNT(f.fileId) as totdocs FROM verifier as v JOIN docs as d ON v.verifierId = d.verifierId JOIN docfiles as f ON d.docId=f.docId GROUP BY v.verifierId, d.docId ORDER BY v.date DESC ) as tots -----[by the help OF BARAND]---- this is query and its working fine, when I add WHERE totdocs = tot2 .... or WHERE totodocs = tot1 its fine and I still get what I need, BUT when it comes to this: WHERE totdocs = tot3 it shows all the record, all I want is the "INCOMPLETE" record only. . By the way, using tot3 and the CASE WHEN it is fine to show the "INCOMPLETE" record, it is when I make a "WHERE totdocs = tot3" statement I got a problem. . Anyone can explain to me why?
  17. Hi all, Today I switched servers. I got a Hostgator Basic Dedicated server, and their migration team moved everything over for my website - including the MySQL database - from their congested shared servers to my new one. I went to my registrar and changed the DNS entries to point to the new private nameservers. Accessed the CPanel, saw the files, was able to modify them and see the changes at the url level. All looked good. Now, here's what's weird: SOME of the pages of my site run the MySQL queries just fine. Some do not. For example, I have a page called "kids rugs" that shows a few hundred rugs pulled straight from my database. Each shows the photo, the name, and the price. But when you click on an individual rug, and it takes you to the detail page? NO data of any kind is showed (no photo, no description, no price, etc...) The second page is running the same type of query as the first. It's a SELECT * FROM tbl_name WHERE category = 'rugs'. The table is the same, the database is the same, and the connection script is the same. But one page shows results from the inquiry where the other does not. There are lots of other pages on my site that refuse to run MySQL inquires as well. These were all inquiries that worked flawlessly on the old shared server, but don't work on the new dedicated one (both servers are Linux). My question is this: Do you think this has anything to do with DNS, non-propagation, etc? I'm tempted to say "oh, this will resolve itself in 24-48 hours", but then again, it doesn't make much sense that a MySQL query would connect and work correctly on one page, and not show any results on others. Any ideas? Thanks in advance for the help!
  18. Hi all, Im trying to populate a drop down list from a php table but for some reason im getting stuck. The table structure is: Table name: Par1AddPatients_dynlist_items Columns: ID, listid, name, value I am trying to populate the list with names and corresponding values from the table, where the list id is ā€˜1ā€™. <select name="ward_list"> <?php $connect = mysql_connect("localhost","username ","password "); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('jasperss_par1pats'); if(!$DB) { die("MySQL could not select Database!"); } $ward_list = mysql_query("SELECT name AND value FROM Par1AddPatients_dynlist_items WHERE listid = '1'"); while ($row = mysql_fetch_array($ward_list)){ echo '<option value="'. $row['value'] .'">'. $row['name'] .'</option>'; } ?> </select> At the moment Iā€™m just getting an empty drop-down box. Any ideas where i'm going wrong? Thanks in advance for any help with this, Matt
  19. OKay so I am trying to make this simply update my mysql server. Can anyone maybe see why this isn't working? The code all works perfectly up until while statement... So if someone maybe sees something wrong? Thanks... <? session_start(); include('nconnect.php'); $uname=$_POST['to']; $result = mysqli_query($con, "SELECT * FROM messages WHERE to='{$uname}' "); $content=$_POST['content']; while($row = mysqli_fetch_array($result)){ mysqli_query($con, "UPDATE messages SET content='{$content}' WHERE to='{$uname}' "); header('location: p1.php'); } ?>
  20. I am working on a website, where you can have accounts and status'. I want to create a "recent status updates" area but I need a little help. Is there a way to like, check recent updates to a mysql database? like check how recently under the table member the area "status" has been updated? if anyone could point in the right direction for this, it would be quite helpful. And if you maybe need more info to help me, let me know. Thanks!
  21. Okay so I have a completely fully functional member system. Login works, register works, In this system I dont let people make two accounts with the same name, however if they have caps in different spots, it works. Any ideas how to prevent this? Any help is much appreciated! Thanks!
  22. hello I have a query which is long, but the main section I have a question about is GROUP BY id ORDER BY id DESC LIMIT 10 this works ok and gives me the first 10 records in descending order, so it gets oldest to newest what do I need to do, to keep the query (first 10 records) but order by newest to oldest can anyone help me, I've searched high and low, and tried lots of ideas, but cannot get it to work right thanxs
  23. I will paste the code below. Okay so I've benn trying to work with SQL in php connecting to a MySQL Database I have hosted on my own computer. I am trying to use an HTML form to get in info I need. But when I hit SUBMIT I don't get the output I was looking for. Any ideas why my code wont work? Also, I am sorry if this is the wrong section, I am new to the forum, if this is the wrong section, can someone please point me to where i need to go? Thanks! <html> <form action="index.php" method="post"> <input type="text" name="username"><br> <input type="text" name="password"><br> <input type="submit"> </form> </html> <?php $uname = $_POST[username]; $pword = $_POST[password]; $con=mysqli_connect('localhost', 'root2', '', 'first_db'); //Check conbnection if(mysqli_connect_errno()) { echo 'Failed to connect: ' . mysqli_connect_error(); } else{ $result = mysqli_query($con,"SELECT * FROM members WHERE username=$uname"); while($row = mysqli_fetch_array($result)) { echo $row['username']; echo $row['password']; echo $row['id']; } }
  24. I have 4 studies that I need to display on a page. I was printing them in order, but I would like to make a partition that clearly distinguishes each section, studyID and studyName. Here is the code thus far: $sql = 'SELECT * FROM tbl_studies'; $list = mysqli_query($dbcon, $sql); $numRecords = mysqli_num_rows($list); for ($i = 1; $i < $numRecords ; $i++){ $sql1 = 'SELECT * FROM tbl_studies JOIN tbl_childinformation ON tbl_studies.studyID = tbl_childinformation.studyID JOIN tbl_parentinformation ON tbl_childinformation.parentID = tbl_parentinformation.parentID'; $list1 = mysqli_query($dbcon, $sql1); $record1 = mysqli_fetch_assoc($list1); echo "<center>----------------------------------------------------------------------<br>"; echo "<center>" . $record1['studyID'] . ' ' . $record1['studyName'] . "</center>"; echo "----------------------------------------------------------------------</center><br />"; $sql = "SELECT * from tbl_studies JOIN tbl_childinformation ON tbl_studies.studyID = tbl_childinformation.studyID JOIN tbl_parentinformation ON tbl_childinformation.parentID = tbl_parentinformation.parentID WHERE tbl_childinformation.studyID = '$record1[studyID]'"; $list = mysqli_query($dbcon, $sql); while($record = mysqli_fetch_assoc($list)){ $newbirthdate = date('m/d/Y', strtotime($record['dateOfBirth'])); $newstudydate = date('m/d/Y', strtotime($record['dateOfStudy'])); echo $record['studyID'] . ' ' . $record['studyName'] . '<br>'; echo "<p class = \"smallerfont\"><em>ID:</em> " . $record['childID'] . "<p class = \"smallerfont\"><em>Name:</em> " . $record['childFirstName'] . ' ' . $record['childLastName'] . "<p class = \"smallerfont\"><em>Date of Birth:</em> " . $newbirthdate . "<p class=\"smallerfont\"><em>Twin?:</em> " . ($record['twin'] == 1 ? 'Yes' : 'No') . "<p class = \"smallerfont\"><em>Medical Conditions:</em> " . $record['medicalConditions'] . "<p class = \"smallerfont\"><em>StudyID:</em> " . $record['studyID'] . "<p class=\"smallerfont\"><em>Date of Study:</em> " . $newstudydate . '<br /><br />'; echo "<div id=\"parentblock\">"; echo "<a id= \"parentlink\" href=\"parentinformationlink.php?pid=" . $record['parentID'] . "\"> Link to " . $record['parentOneFirstName'] . ' ' . $record['parentOneLastName'] . (empty($record['parentTwoFirstName']) ? '</a>':' and ' . $record['parentTwoFirstName'] . ' ' . $record['parentTwoLastName']) . "</a>"; echo "</div>"; } } So basically, I figured I could count the number of studies there are after querying the tbl_studies, and then for a for loop, and only print the children that have matching studyID's. Works great for the first loop, but I need to reference the 2nd record, and so on. Is there a way to achieve this in php? Any advice is greatly appreciated!
  25. Hello, i have a table i have to fill out with info regarding other tables, is a join possible or do i have to make 2 queries? This is what i have right now. $date = date("Y-m-d H:i:s"); $sql = "INSERT INTO tblpaqueteria ( sender_id, reciever_id, AddTime, Estatus, ubicacion, tipo,slocalidad_id,rlocalidad_id ) VALUES ( '{$_POST['id_send']}', '{$_POST['id_rec']}', '{$date}', '0' , '0', '{$_POST['tipo_paq']}',0,0 )"; $res = mysql_query($sql,$this->conn); return $sql; What i need now is to change some of my insert into dynamic ones, i have to enter into "slocalidad_id" and into "ubicacion" the "id" of a table called localidad, and this id is being referenced from a table called "usuarios" (users) where "$_POST['id_send']" where localidad_id marks the id i need to insert into tblpaqueteria. I am not sure if I explained myself correctly so ill try and make an example. usuarios So for my sql above, without joins i would be receiving from POST id_send = 2 and from id_rec 11 so my query should insert this $sql = "INSERT INTO tblpaqueteria ( sender_id, reciever_id, AddTime, Estatus, ubicacion, tipo,slocalidad_id,rlocalidad_id ) VALUES ( '{$_POST['id_send']}', '{$_POST['id_rec']}', '{$date}', '0' , '2', '{$_POST['tipo_paq']}',2,4 )"; notice the numbers "2" and "4" being inserted, those are the ones i don't know how to enter dynamically, i think its a join, but i don't know how to use them in an insert. Thanks a lot
×
×
  • 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.