Jump to content

Search the Community

Showing results for tags 'php mysql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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 (Dreamweaver, Zend, 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. I have below script. it does the while loop 100%. it updates the mysql database one at a time as it should. the problem I have now is that the while loop does not end and go to the next statement as it should. it keeps pollong the database. so when in back end you change to 0 it automatically updates again. Please see if you can help me to see where I can stop this while loop when there are no more loops // Here I select the amount of rows $sql_query = "SELECT ae FROM `debitorderrejectionimport` WHERE ae = '0'"; $rowCount = mysqli_query($conn,$sql_query); $rowCountUpdate = mysqli_num_rows($rowCount); echo $rowCountUpdate; while($rowCountUpdate > 0) { $sql = "UPDATE `ttee`.`au1` INNER JOIN `ttee`.`au` ON (`au1`.`id` = `au`.`id`) INNER JOIN `ttee`.`ae1` ON (`ae1`.`idd` = `au1`.`idd`) INNER JOIN `ttee`.`debitorderrejectionimport` ON (`debitorderrejectionimport`.`nr` = `ae1`.`id`) SET `au`.`amount` = `ae1`.`amount` + `au1`.`amount`, `debitorderrejectionimport`.`ae` = au.id ;"; $result = mysqli_query($conn, $sql); $updated = mysqli_affected_rows($conn); $rowCountUpdate - ($updated);} // if it finished updating and there is no more rows it must continue with below query mysqli_query($conn, " INSERT INTO `sataxicrm754`.`debitorderrejectionimport_back` ( `Outbound`, `Allocation`, `AccountName`, `QueryComplaintType`, `QueryStatus`, `Querytypeoption`, `Description`, `DealID`, `Deals`, `Assignedusername`, `Teams`, `CampaignName`, `CampaignID`, `inserted`, `idnumber`, `nr`, `datew`, `premium`, `policynumber`, `ContactNumber`, `CollectionType`, `OpportunityAmount`, `Broker`, `impref`, `id` ) SELECT `Outbound`, `Allocation`, `AccountName`, `QueryComplaintType`, `QueryStatus`, `Querytypeoption`, `Description`, `DealID`, `Deals`, `Assignedusername`, `Teams`, `CampaignName`, `CampaignID`, `inserted`, `idnumber`, `nr`, `datew`, `premium`, `policynumber`, `ContactNumber`, `CollectionType`, `OpportunityAmount`, `Broker`, `impref`, `id` FROM `sataxicrm754`.`debitorderrejectionimport` WHERE QueryComplaintType <> 'QueryComplaintType' ");
  2. Hi all, My server config is as below Server version: Apache/2.4.18 (Ubuntu) PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS ) mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper I have this following bit of code. It runs up-to a point, indicated by the comments in code, and then vanishes totally. There is no error and there is no output either. I have display errors and mysqli reporting on and set as below: ini_set("display_errors",1); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqliDriver = new mysqli_driver(); $mysqliDriver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT; case "VS": $prestr = $sent_result[8]; $STATUS = $prestr."Status"; $SUMS = $prestr."Sums"; $PCT = $prestr."PCT"; $DPM = $prestr."DPM"; $TIMETAKEN = $prestr."TimeTaken"; $SPEEDDIGITS = $prestr."SpeedDigits"; $SPEEDSUMS = $prestr."SpeedSums"; $MODULE = $prestr."mistakes"; if($STATUS=='1'){ throw new Exception("VISUAL GADBAD"); } $v_sums_correct = $sent_result[1]; $v_time_in_seconds = $sent_result[2]; $v_delay_digit_ms = $sent_result[3]; $v_delay_sum_ms = $sent_result[4]; $v_dpm = $sent_result[5]; $v_pct = $sent_result[6]; $v_WA = $sent_result[7]; $con->autocommit(false); $commit_flag = true; $query = "SELECT EXISTS(SELECT 1 from vis_mistakes where UserLogin=? AND DayID = ?) as `mistakesCheck`"; $stmt = $con->prepare($query); $stmt->bind_param('si',$user,$dayNum); if($stmt->execute()) { $stmt->bind_result($mistakesCheck); $stmt->fetch(); $stmt->free_result(); if($mistakesCheck === 0) { // echo "MODULE : ".$MODULE."<br>"; echo "Inside Insert Mistakes<br>"; $query = "INSERT into `vis_mistakes` (DayID,UserLogin,$MODULE) VALUES (?,?,?)"; $stmt = $con->prepare($query); $stmt->bind_param('iss',$dayNum,$user,$v_WA); }else { echo "Inside Update Mistakes<br>"; $query = "UPDATE vis_mistakes SET $MODULE = ? WHERE UserLogin = ? AND DayID = ?"; $stmt = $con->prepare($query); $stmt->bind_param('ssi',$v_WA,$user,$dayNum); // OR die("Bound Fail Vis". $con->error); } // echo $no_of_logins." : ".$time_of_nLogin." : ".$v_sums_correct." : ".$v_pct." : ".$v_dpm." : ".$v_time_in_seconds." : ".$v_delay_digit_ms." : ".$v_delay_sum_ms." : ".$date." : ".$RecNo."<br><br>"; // echo "<br>".$SUMS." : ".$PCT." : ".$DPM." : ".$TIMETAKEN." : ".$SPEEDDIGITS." : ".$SPEEDSUMS." : ".$STATUS."<br><br>"; // ********** // vanishes beyond here ******* !!!!!! if($stmt->execute()) { echo "Generating Query"; // ********* does not display this echo ************* // $query = "UPDATE mysessdata SET no_of_logins = ?, time_of_nLogin = ?, $SUMS = ?, $PCT = ?, $DPM = ?, $TIMETAKEN = ?, $SPEEDDIGITS = ?, $SPEEDSUMS = ?, $STATUS = 1, TimeOfLogout = ? WHERE RecNo = ?"; $stmt = $con->prepare($query); $stmt->bind_param('isiddsiisi',$no_of_logins, $time_of_nLogin, $v_sums_correct, $v_pct, $v_dpm, $v_time_in_seconds, $v_delay_digit_ms, $v_delay_sum_ms, $date, $RecNo); echo "<br>"; echo $query; echo "<br>"; if($stmt->execute()) { echo "<br>Query executed<br>"; $query = "SELECT $SUMS,$TIMETAKEN,no_of_logins,$SPEEDDIGITS,$SPEEDSUMS FROM $table WHERE RecNo = ? AND $STATUS = 1"; $stmt=$con->prepare($query); $stmt->bind_param('i',$RecNo); if($stmt->execute()) { $stmt->bind_result($vsc,$vtt,$no_of_logins,$VDS,$VSS); $stmt->store_result(); $stmt->fetch(); $stmt->free_result(); $arr_result =array($datatype,$vsc,0,$vtt); // echo "<br>vsc = ".$vsc; // server_mod // echo " vtt = ".$vtt; // server_mod // echo " Visual Record Updated. <br>"; // server_mod // echo " Visual Speed Digits = ".$VDS; // echo " Viasual Speed SUMS = ".$VSS; } $con->commit(); $con->autocommit(true); } else { // ** does not even print this, the else from above !!!!!! // echo "<br>MeesUP"; throw new Exception("ERROR : 1-V"); } }else throw new Exception("ERROR : 2-V"); }else throw new Exception("ERROR : 3-V"); if($commit_flag===false) { mysqli_rollback($con); throw new Exception("Visual"); } echo " exiting"; break; SNAPSHOTS OF MY DATABASE The NULL values should be changed (updated or inserted). The output from running the above code is as below : The database file, just in case :? -- MySQL dump 10.13 Distrib 5.7.22, for Linux (x86_64) -- -- Host: localhost Database: mysessdb -- ------------------------------------------------------ -- Server version 5.7.22-0ubuntu0.16.04.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `mysessdata` -- DROP TABLE IF EXISTS `mysessdata`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mysessdata` ( `RecNo` int(11) NOT NULL AUTO_INCREMENT, `UserLogin` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, `Level` tinyint(4) NOT NULL, `SessionStatus` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `TimeOfLogin` datetime DEFAULT NULL, `Wrt_W_Sums_R1` tinyint(4) DEFAULT NULL, `Wrt_W_Sums_R2` tinyint(4) DEFAULT NULL, `Wrt_W_PCT` float(10,2) DEFAULT NULL, `Wrt_W_DPM` float(10,2) DEFAULT NULL, `Wrt_W_TimeTaken` smallint(6) DEFAULT NULL, `Wrt_W_Status` tinyint(4) DEFAULT NULL, `Wrt_V_Sums` tinyint(4) DEFAULT NULL, `Wrt_V_PCT` float(10,2) DEFAULT NULL, `Wrt_V_DPM` float(10,2) DEFAULT NULL, `Wrt_V_TimeTaken` smallint(6) DEFAULT NULL, `Wrt_V_SpeedDigits` smallint(6) DEFAULT NULL, `Wrt_V_SpeedSums` smallint(6) DEFAULT NULL, `Wrt_V_Status` tinyint(4) DEFAULT NULL, `Wrt_O_Sums` tinyint(4) DEFAULT NULL, `Wrt_O_PCT` float(10,2) DEFAULT NULL, `Wrt_O_DPM` float(10,2) DEFAULT NULL, `Wrt_O_TimeTaken` smallint(6) DEFAULT NULL, `Wrt_O_SpeedDigits` smallint(6) DEFAULT NULL, `Wrt_O_SpeedSums` smallint(6) DEFAULT NULL, `Wrt_O_Status` tinyint(4) DEFAULT NULL, `TimeOfLogout` datetime DEFAULT NULL, PRIMARY KEY (`RecNo`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `mysessdata` -- LOCK TABLES `mysessdata` WRITE; /*!40000 ALTER TABLE `mysessdata` DISABLE KEYS */; INSERT INTO `mysessdata` VALUES (1,'mina12345',1,'1','2018-01-13 16:48:26',4,0,20.00,45.00,16,1,4,80.00,9.35,77,2500,5000,1,4,80.00,11.43,63,2500,2500,1,'2018-01-13 17:48:26'),(2,'mina12345',1,NULL,'0000-00-00 00:00:00',1,20,43.00,18.00,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `mysessdata` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `vis_mistakes` -- DROP TABLE IF EXISTS `vis_mistakes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `vis_mistakes` ( `SNo` bigint(11) NOT NULL AUTO_INCREMENT, `UserLogin` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `DayID` smallint(11) NOT NULL, `Wrt_V_mistakes` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `Mtl_V_mistakes` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `Mul_V_mistakes` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `Div_V_mistakes` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`SNo`) ) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `vis_mistakes` -- LOCK TABLES `vis_mistakes` WRITE; /*!40000 ALTER TABLE `vis_mistakes` DISABLE KEYS */; INSERT INTO `vis_mistakes` VALUES (1,'mina12345',1,'3,',NULL,NULL,NULL),(2,'ranveer09',1,'4,5,',NULL,NULL,NULL),(35,'mina12345',2,'2,3,',NULL,NULL,NULL); /*!40000 ALTER TABLE `vis_mistakes` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2018-07-24 12:27:22 Strangely this very code works just great on my old machine where the mysql version is 5.6 php is 7.0.27 and almost the same apache version. It simply does not display or log any errors. I am totally stumped. Gurus Please help !! Thanks all !
  3. Hi, I am almost done my assignment however I am having an issue. I am trying to read enrolment and if the student is already registered for the course then print an error. However I am only able to register one student in one course each before getting the error message, which leads me to believe that it isn't reading the enrolment file properly. I seam to have an issue with this. Any help would be grateful. Thank you // if the course is found and the student is found then check if they have registered if ($found==3) { $equery= "SELECT * FROM enrolment WHERE uid ='$number' AND code = '$course'"; $eresult= mysqli_query($link, $equery); while ($erow = mysqli_fetch_array($eresult)) { if ($erow['code'] == $course && $number == ($erow['uid'])) { } // if ($erow['code'] == $course && $number == ($erow['uid'])) } // while ($erow = mysqli_fetch_array($eresult)) } // if ($found==3) //if the student isn't registered in the course $equery = "INSERT INTO enrolment(uid,code) VALUES ('$number','$course')"; if (mysqli_query($link, $equery)) { echo "New record created successfully"; }// if (mysqli_query($link, $equery)) else { echo "Error: You have already registered for the course"; } // else echo "Error: " .$link->error; mysqli_close ($link);
  4. hi, can anyone advise regarding practice of displaying data from a database to the end user. If you creating 1 large table with a lot of stats in for users, should you have have 1 massive select statement or do it in individual statments like i have. my code works ok but i cant work out how to get the 'Total Year' column to populate..the stats i want appear under the user id's...(see attached jpeg) $result = mysqli_query($conn,"SELECT u.company_id, u.name ,u.surname, u.id, count(f.date_made) as num_rows FROM users u LEFT JOIN firsts f ON u.id = f.usr_id group by u.id having u.company_id='".$_SESSION['company_id']."' ") ; while($firsts=mysqli_fetch_array($result)){ echo "<tr>"; //changes date to english format from a time stamp echo"<td>".$firsts['company_id']."</td>"; echo"<td>".$firsts['id']."</td>"; echo"<td>".$firsts['name']. ' '.$firsts['surname']."</td>"; echo"<td>".$firsts['num_rows']."</td>"; //echo"<td>".$firsts['date_mades']."</td>"; } $result1 = mysqli_query($conn,"SELECT u.company_id,u.name,u.surname, u.id, count(f.date_made) as date_mades FROM users u LEFT JOIN firsts f ON u.id = f.usr_id AND DATE(f.date_made) and year(curdate()) = year(date_made) group by u.id having u.company_id='".$_SESSION['company_id']."' "); while($firsts=mysqli_fetch_array($result1)) //echo "<tr>"; { echo "</tr>"; echo"<td>".$firsts['date_mades']."</td>"; } $result = mysqli_query($conn, "SELECT count(f.date_made) as date_mades FROM users u LEFT JOIN firsts f ON u.id = f.usr_id and u.company_id='".$_SESSION['company_id']."' "); while($firsts=mysqli_fetch_array($result)){ echo "<tr>"; echo"<td>".'Total'."</td>"; echo"<td>"; echo"<td>"; echo"<td>".$firsts['date_mades']."</td>"; //echo"<td>".$firsts['date_madess']."</td>"; } ?>
  5. I need help on the code for adding int values to a database. I am keeping scores each week for a poker club and each week I need to add the scores into the database so that it shows the total on the webpage. The page would look like this Name: Score: and the total scores page would be a table with the name on the left and total score on the right. It is very important that I can add scores each week that add on top of the total score for that player. Cheers Also the tables have already been created on mySQL
  6. Hi, I need some help. I dont really know what is wrong with my code. It seems not to work. The reg.php does not send the data into the database and the log in can not query the database either. I need help. HELP ME PLEASE <?php require 'database-config.php'; session_start(); $username = ""; $password = ""; if(isset($_POST['username'])){ $username = $_POST['username']; } if (isset($_POST['password'])) { $password = $_POST['password']; } echo $username ." : ".$password; $q = 'SELECT * FROM users WHERE username=:username AND password=:password'; $query = $dbh->prepare($q); $query->execute(array(':username' => $username, ':password' => $password)); if($query->rowCount() == 0){ header('Location: index.php?err=1'); }else{ $row = $query->fetch(PDO::FETCH_ASSOC); session_regenerate_id(); $_SESSION['sess_user_id'] = $row['id']; $_SESSION['sess_username'] = $row['username']; $_SESSION['sess_userrole'] = $row['role']; echo $_SESSION['sess_userrole']; session_write_close(); if( $_SESSION['sess_userrole'] == "admin"){ header('Location: adminhome.php'); }else{ header('Location: userhome.php'); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> <style> body { background-color: white; padding-top: 40px; } .input-group-addon { background-color: rgb(50, 118, 177); border-color: rgb(40, 94, 142); color: rgb(255, 255, 255); } .form-control:focus { background-color: rgb(50, 118, 177); border-color: rgb(40, 94, 142); color: rgb(255, 255, 255); } .form-signup input[type="text"],.form-signup input[type="password"] { border: 1px solid rgb(50, 118, 177); } </style> </head> <body> <div class="container"> <div class="row"> <div class="col-md-6 col-md-offset-3"> <div class="panel panel-default"> <div class="panel-body"> <form class="form-horizontal" method="POST" action="process_user.php"> <fieldset> <!-- Form Name --> <legend>User registration</legend> <!-- Text input--> <div class="form-group"> <label class="col-md-4 control-label" for="user">Username:</label> <div class="col-md-6"> <input id="user" name="username" type="text" placeholder="" class="form-control input-md" required=""> </div> </div> <!-- Password input--> <div class="form-group"> <label class="col-md-4 control-label" for="pass">Password:</label> <div class="col-md-6"> <input id="pass" name="password" type="password" placeholder="" class="form-control input-md" required=""> </div> </div> <!-- Multiple Radios (inline) --> <div class="form-group"> <label class="col-md-4 control-label" for="user_type">User type:</label> <div class="col-md-4"> <label class="radio-inline" for="user_type-0"> <input type="radio" name="user_type" id="user_type-0" value="admin" > Admin </label> <label class="radio-inline" for="user_type-1"> <input type="radio" name="user_type" id="user_type-1" value="user"> User </label> </div> </div> <!-- Button --> <div class="form-group"> <label class="col-md-4 control-label" for="submit"></label> <div class="col-md-4"> <button id="submit" name="submit" class="btn btn-primary">Create new user</button> </div> </div> </fieldset> </form> </div> </div> </div> </div> </div> </body> </html> <?php require 'database-config.php'; if(!empty($_POST)) { // Ensure that the user has entered a non-empty username if(empty($_POST['username'])) { die("Please enter a username."); } // Ensure that the user has entered a non-empty password if(empty($_POST['password'])) { die("Please enter a password."); } $query = " SELECT id FROM users WHERE username = :username "; $query_params = array( ':username' => $_POST['username'] ); try { // These two statements run the query against your database table. $stmt = $dbh->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $row = $stmt->fetch(); if($row) { die("This username is already in use"); } $query = " INSERT INTO users ( username, password, salt, role ) VALUES ( :username, :password, :salt, :user_type ) "; $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647)); $password = hash('sha256', $_POST['password'] . $salt); $query_params = array( ':username' => $_POST['username'], ':password' => $password, ':salt' => $salt, ':role' => $_POST['user_type'] ); try { $stmt = $dbh->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } header("Location: index.php"); die("Redirecting to index"); } ?>
  7. I need Delete Duplicate Email Records That Are Attached To One Account But Can Be Found In Multiple Accounts I have a table, consumer_mgmt. It collects consumer information from various forms. These forms are available through different pages that are part of a business package. A business can offer these signups to gather names and emails from consumers for various types of specials they may offer. So a consumer my be in the consumer_mgmt table 5, 10, 15 times for that particular business. But, that consumer may be in the consumer_mgmt table multiple times for a different business. So multiple times for multiple businesses. I need to remove duplicates for each business account so the consumer is only the consumer_mgmt only once for each business. There are approximately 15,000 rows currently in the consumer_mgmt table. I'm not sure where to begin on the logic. Since there are multiple business accounts that the emails are attached to, would one have to build a case for each loop?
  8. I do not have code yet, i just want a general idea how to get started. I have a database with +/- 15 columns. 6 people are using this database. Not all columns are relevant for each user. So my idea was that each user will be able to make his preference by checking checkboxes for each column -> store this in the database so that when he logs in , his preference will be retrieved and used to make the right query. second question, how do i make the headers so that they are the same als the preferences from the user ? Just put me on the right track (or if someone has it on the shelf, post the code) thanks in advance
  9. Happy New Year from a Newbie. I have data in a MySql database table (let's call it data_table) which is input by users via a form. Their input consists of one or a list of items seperated by spaces. This ends up in one column (let's call it data_col) as in the following example format: id data_col 1 cat 2 elephant giraffe 3 dog rabbit 4 snake cat bird 5 fish dog .. etc. I need help with a PHP script to read only this column into a string variable with which I can then (a) use explode to seperate it into an array containing the seperated words and removing the spaces, if any, at the same time and (b) use array_unique to remove any duplicated words in the array, before finally displaying the array as an A-Z ordered list as below. bird cat (duplicate removed) dog (duplicate removed) elephant fish giraffe rabbit snake Many thanks for any help offered.
  10. Hello dear members, first of all sorry for my grammer i'm from Switzerland . So now: I have a problem with php. I want to put out the date of a blogpost in this format dd:mm:yyyy instead of yyyy:mm:dd. I tried it a long time and used many different ways like: date, dateformat, strto etc. but at the and nothing worked for me. So here is a picture of the blogpost and i'll add the file with my compressd php code. I'd be glad if you could help me Regards Mr_Ironic help.php
  11. Hi I making some forms that write to mysql database, Im now in the process of making the update form so the user can update there details on the form, I want it to populate the form with existing data but its not doing it at all. Thanks in advance delete.php modify.php index.php
  12. First of all, I apologize for my "newbieness" in advance. I've got a form processing script that is working fine except for one section of code, snippets of which is shown below: //default values $formResponse = "How are you really doing? Use this to find out!"; $imgSource = "blue.png"; If ($country == "United States") { //US zip code query $sql = "SELECT location, revParData FROM zipData WHERE zipCode = '$zipCode' LIMIT 1"; mysql_select_db('db'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { $formResponse = "It looks like you entered an invalid zip code. Please try again!"; $imgSource = "yellow.png"; } else { $sql = "SELECT location, revParData FROM zipData WHERE zipCode = '$zipCode' LIMIT 1"; mysql_select_db('db'); $retval = mysql_query( $sql, $conn ); while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { $location = $row['location']; $revParData = $row['revParData']; } } What I thought would happen is this: If the zip code entered by the end user does not exist in the table, the $formResponse and $imgSource values would be the "... invalid zip code" and "yellow.png" values. If a valid zip code is entered, it completes the second query. In fact, it works fine if a zip code that exists in the table is entered, but shows the default values for $formResponse and $imgSource if a zip code that doesn't exist in the database is entered. I can't figure out why it is doing this... if anyone can point out my coding error, it would be appreciated. Cheers! Mike
  13. I have database "raj" with table "pagination" In table pagination have "id", "actualtime" and "created" field id - auto_increment actualtime- varchar created- datetime that looks like this CREATE TABLE pagination( id int auto_increment, actualtime varchar(55), created datetime ) I want to display all rows which are created on todays date and will display from today upto yesterday at 06:00 pm. after that the content will be refreshed based on based on a DATETIME field called 'created' that holds the date and time of each record's creation. this is my query to fetch rows but it display value after 06:00 pm on yesterday but i want to display all data before 06:00 pm from currentdate. After 06:00 pm data will be refreshed and clear. plz help me...... SELECT actualtime FROM pagination WHERE created BETWEEN date_add(date_sub(curdate(), INTERVAL 1 day), INTERVAL 18 hour) AND curdate()";
  14. I can not get the values from the javascript add row to go dynamically as a row into MySql only the form values show up as the form below as one row. I made it as an array, but no such luck, I have tried this code around a multitude of ways. I don't know what I am doing wrong, kindly write out the correct way. <!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=utf-8" /> <title>Dynamic Fields js/php to MySql need to submit dynamically to the database</title> <?php require ('database.php'); ?> <script type="text/javascript"> var counter = 1; var collector = ""; function addfields(indx) { var tbl = document.getElementById('table_id'); var newtr = document.createElement('tr'); counter = counter + indx; newtr.setAttribute('id','tr'+counter); newtr.innerHTML = '<td><input type="checkbox" name="checkb'+counter+'" id="checkb'+counter+'" value="'+counter+'" onclick="checkme('+counter+')"></td><td><input type="text" name="text1[]"></td><td><textarea name="textarea1[]"></textarea></td>'; tbl.appendChild(newtr); } function checkme(dx) { collector += dx+","; } function deletetherow(indx) { var col = collector.split(","); for (var i = 0; i < col.length; i++) { var remvelem = document.getElementById('tr'+col); var chckbx = document.getElementById("checkb"+col); if(remvelem && chckbx.checked) { var tbl = document.getElementById('table_id'); tbl.removeChild(remvelem); } } } </script> </head> <body> <form enctype="multipart/form-data" id="1" style="background-color:#ffffff;" action="<?php echo $_SERVER['PHP_SELF']; ?>"></form> <table id="table_id" > <tr id="tr1" class="trmain"> <td> </td> <td> <input type="text" name="text1[]"> </td> <td> <textarea name="textarea1[]"></textarea> </td> </tr> </table> <input type="button" value="Add" onClick="addfields(1);" /> <input type="button" value="Delete" onClick="deletetherow()" /> <input type="submit" value="Send" id="submit" name="submit"/> <?php if(isset($_POST['submit'])) { for ($i=0; $i < count($_POST['text1']); $i++ ) { $ced = stripslashes($_POST['text1'][$i]); $erg = stripslashes($_POST['textarea1'][$i]); } $bnt = mysql_query("INSERT INTO tablename (first, second) VALUES ('$ced', '$erg')")or die('Error: '. mysql_error() ); $result = mysql_query($bnt); } ?> </body> </html>
  15. I am not sure if the title is correct; I tried my best. I'm a PHP/MySQL beginner and I really need some help. I have a small script that I am using for sending SMS. I recently added a phonebook. The problem with the phonebook right now is that it's available to all users, i.e. they can all update and delete all rows. What I would like to do is make it so that each user can update and delete only their own contacts. I have a table call contacts. Inside that table there is first name, last name, company and phonenumber. How can I accomplish this with PHP & MySQL? CREATE TABLE IF NOT EXISTS `contacts` ( `contact_id` int(10) NOT NULL AUTO_INCREMENT, `firstname` varchar(255) NOT NULL, `lastname` varchar(255) NOT NULL, `company` varchar(255) NOT NULL, `cell_no` text NOT NULL, PRIMARY KEY (`contact_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `users_name` varchar(30) NOT NULL, `uname` varchar(30) NOT NULL, `u_pass` varchar(60) NOT NULL, `utype` varchar(30) NOT NULL, `timezone` varchar(30) NOT NULL, `uapi_user` varchar(30) NOT NULL, `uapi_pass` varchar(60) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ; <?php if (isset($_POST['submit'])){ //form has been submitted1 $firstname = trim($_POST['firstname']); $lastname = trim($_POST['lastname']); $company = trim($_POST['company']); $cellno = trim($_POST['cell_no']); if($firstname == ''){ echo '<div class="alert alert-danger">First Name is not Valid!</div>'; exit; }elseif($lastname == ''){ echo '<div class="alert alert-danger">Last Name is not Valid!</div>'; exit; }elseif($company == ''){ echo '<div class="alert alert-danger">Company is not Valid!</div>'; exit; }elseif($cellno == ''){ echo '<div class="alert alert-danger">Cellphone Number is not Valid!</div>'; exit; }else{ $query = "Select cell_no from contacts where cell_no = '".$cellno."' "; $result = mysql_query($query); if (!mysql_num_rows($result)) { $sql = "INSERT INTO contacts(firstname, lastname, company, cell_no) values('{$firstname}','{$lastname}', '{$company}', '{$cellno}')"; $result = mysql_query($sql); confirm_query($result); //echo '<div class="alert alert-success">Successfully added.</div>'; //exit; ?> <script type="text/javascript"> window.location = "contact_list.php"; </script> <?php } else{ echo '<div class="alert alert-danger">Username. already exist!.</div>'; echo '<p><a href="new_contact.php" class="btn btn-success"> Back </a></p>'; exit; }} }else{ $firstname = ""; $lastname = ""; $company = ""; $cellno = ""; } ?>
  16. I'm getting the dreaded " Invalid parameter number: number of bound variables does not match number of tokens" error and I've looked at this for days. Here is what my table looks like: | id | int(4) | NO | PRI | NULL | auto_increment | | user_id | int(4) | NO | | NULL | | | recipient | varchar(30) | NO | | NULL | | | subject | varchar(25) | YES | | NULL | | | cc_email | varchar(30) | YES | | NULL | | | reply | varchar(20) | YES | | NULL | | | location | varchar(50) | YES | | NULL | | | stationery | varchar(40) | YES | | NULL | | | ink_color | varchar(12) | YES | | NULL | | | fontchosen | varchar(30) | YES | | NULL | | | message | varchar(500) | NO | | NULL | | | attachment | varchar(40) | YES | | NULL | | | messageDate | datetime | YES | | NULL | Here are my params: $params = array( ':user_id' => $userid, ':recipient' => $this->message_vars['recipient'], ':subject' => $this->message_vars['subject'], ':cc_email' => $this->message_vars['cc_email'], ':reply' => $this->message_vars['reply'], ':location' => $this->message_vars['location'], ':stationery' => $this->message_vars['stationery'], ':ink_color' => $this->message_vars['ink_color'], ':fontchosen' => $this->message_vars['fontchosen'], ':message' => $messageInput, ':attachment' => $this->message_vars['attachment'], ':messageDate' => $date ); Here is my sql: $sql = "INSERT INTO messages (user_id,recipient, subject, cc_email, reply, location,stationery, ink_color, fontchosen, message,attachment) VALUES( $userid, :recipient, :subject, :cc_email, :reply, :location, :stationery, :ink_color, :fontchosen, $messageInput, :attachment, $date);"; And lastly, here is how I am calling it: $dbh = parent::$dbh; $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); if (empty($dbh)) return false; $stmt = $dbh->prepare($sql); $stmt->execute($params) or die(print_r($stmt->errorInfo(), true)); if (!$stmt) { print_r($dbh->errorInfo()); } I know my userid is valid and and the date is set above (I've echo'd these out to make sure). Since the id is auto_increment, I do not put that in my sql (though I've tried that too), nor in my params (tried that too). What am I missing? I feel certain it is something small, but I have spent days checking commas, semi-colons and spelling. Can anyone see what I'm doing wrong?
  17. Hi There, I would like my webpage title to change for each sub-site that I visit say I go to player A I want the website name to say CNGHLDB-Player A and If I go to player B profile it would change to say CNGHLDB-Player B I have the names in my php script so I am assuming it shouldn't be to hard to do the coding for it, but I am not sure how to do it. <title>CNGHLDB</title> </head> <? // Connects to your Database mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); //Get PlayerID from URL $iPlayerID = $_GET["PlayerID"]; $iNationID = $_GET["NationID"]; $oPlayerInfo = mysql_query(" SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam FROM Players Left JOIN CNGHLTeams ON Players.CNGHLID=CNGHLTeams.CNGHLID Left JOIN NHLTeams ON Players.TeamsID=NHLTeams.TeamID Left JOIN Countries ON Players.NationID=Countries.NationID Left JOIN DraftTeam ON Players.DraftID=DraftTeam.DraftID WHERE Players.PlayerID=$iPlayerID ORDER BY Players.LastName; ") or die(mysql_error()); while($row = mysql_fetch_array($oPlayerInfo)) { Print "<body>"; ECHO "<div align='center'>"; ECHO "<table width='496' border='0'>"; ECHO "<tr>"; ECHO "<td width='148'><div align='center'><a href=\"http://www.cnghl.org/cnghldb/index.php\"><strong>SEARCH PLAYERS</strong></a></div></td>"; ECHO "<td width='152'><div align='center'><a href=\"http://www.cnghl.org/cnghldb/goaliesearch.php\"><strong>SEARCH GOALIES</strong></a></div></td>"; ECHO "<td width='182'><div align='center'><strong><a href=\"http://www.cnghl.biz/history/league.html\">FRANCHISE HISTORY</a></strong></div></td>"; ECHO "</tr> </table> </div> <p align='center'> </p> <p>"; Print "<center> </p> <div align='center'> <table width='700' border='0'> </center>"; Print "<tr>"; Print "<td colspan='3'><h1>".$row['FirstName']." ".$row['LastName']." <img src=\"http://www.cnghl.org/cnghldb/nation/".$row['NationID'].".gif\"></h1></td>"; Print "</tr>"; Print "<tr>"; Print "<td width='300' height='26'><strong>Birthdate: </strong>".$row['DOB']."</td>"; $DOB = $row[DOB]; //dd.mm.yyyy $user_date = new DateTime($DOB); $curr_date = new DateTime(); $age_cal = $curr_date->diff($user_date); Print "<td width='525'><strong>Age: </strong>".$age_cal->y;"</td>"; Print "<td style='vertical-align:top;'width='275' rowspan='10'><div align='center'><img src=\"http://www.cnghl.org/cnghldb/images/".$iPlayerID.".jpg\">"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Nation: </strong>".$row['Nation']."</td>"; Print "<td><strong>CNGHL Team: </strong>".$row['CNGHLRights']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Position: </strong>".$row['Position']. "</td>"; Print "<td><strong>Weight: </strong>".$row['Weight']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Height: </strong>".$row['Height']. "</td>"; Print "<td><strong>NHL Team: </strong>".$row['Team']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Draft Year: </strong>".$row['CNDraftYR']."</td>"; Print "<td><strong>Draft Position: </strong>".$row['CNDraftPOS']."</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Drafted By: </strong>".$row['DrTeam']."</td>"; Print "<td> </td>"; Print "</tr>"; Print " <tr> <td height='179' colspan='2'> </td> </tr> The coding that pulls there names that I would want to use is Firstname and Lastname or I have the simpler full name that include both first and last names. Thanks for your help!
  18. hi im new to php im using a script that i found at the link below: http://forums.devshed.com/php-faqs-stickies-167/program-basic-secure-login-system-using-php-mysql-891201.html It works fine but i have added a couple of fields to the database : telephone and mobile_telephone Ive change the register.php to include these fields but im struggling with the edit_account Could anyone help please
  19. One image is displaying but when i choose image 2 it overlaps image 1..gallery.php
  20. I'm just starting out with mysqli and php. Actually I more or less know how to create/connect/populate mysqli databases through php. But I can only do so by using a separate php page for each objective. Anyway, I learning with the kindle version of Joy of Php. The code though isn't very good...I had to edit it just to make it conform to php/mysqli syntax. Programmer's Notebook was a big help actually. Anyway, I just wanted to point out my experience level. Below is the code, I haven't run it through wamp (Phpmyadmi) yet, only because it probably won't run and I'll be crushed...side note: it took me a while to figure out that tables and databases require the use ` and not '. The book doesn't even mention the difference!!!! Anyway, can someone tell me if this edited code is viable? I'm concerned about line 4: $mysqli.... since this is wamp, and I log into phpmyadmin via -u root -p , -p NULL in the code is correct yes? <?php /*Joy of PHP sample code*/ $mysqli = new mysqli('localhost', 'root', NULL ); if (mysqli_connect_error()) { die('Could not connect: ' . mysqli_connect_error()); } echo 'Connected successfully to mySQL.'; /* Create table doesn't return a resultset */ if ($mysqli->query("CREATE DATABASE Cars") === TRUE) { echo "Database Cars created"; } else { echo "Error creating Cars database: " . $mysqli->error."<br>"; } $mysqli->select_db("Cars"); Echo ("Selected the Cars database"); $query= " CREATE TABLE INVENTORY (VIN varchar(17) PRIMARY KEY, YEAR INT, Make varch(50), Model varchar(100))"; //echo "<p>*****</p>"; //echo $query; //echo "<p>*****</p>"; if ($mysqli->query ($query) === TRUE) { echo "<p>Database table 'INVENTORY' CREATED</p>"; } else { echo "<p> ERROR: </p>" . mysqli_error($mysqli); } $query = "INSERT INTO `cars` . `inventory` (`VIN`, `YEAR`, `Make`, `Model`) VALUES '5FNYF4H91CB054036', '2012', 'Honda', Pilot')"; if ($mysqli->query($query) === TRUE) { echo "<p>Honda Pilot inserted into inventory table. </p>"; } else { echo "<p>Error inserting Honda Pilot:</p>" . mysqli_error($mysqli); echo "<p>*****</p>"; echo $query; echo "<p>*****</p>"; } //Insert a Dodge Durango $query= "INSERT INTO `cars` . `inventory` ('VIN', 'YEAR', 'Make', 'Model') VALUES ('LAKSDFJ234LASKRF2', '2009', 'Dodge', 'Durango')"; if ($mysqli->query($query) ===TRUE) { echo "<p>Dodge Durango inserted into inventory table </p>"; } else { echo "<p>Error inserting Dodge: </p>" . mysqli_error($mysqli); echo "<p>*****</p>"; echo $query; echo "<p>*****</p>"; } $mysqli->close(); ?> Thank you, I apologize if I seem critical of the book but it really skips over A LOT of stuff that newbies don't necessarily know (example: -u something -p = username something and password is blank)
  21. File wont move to directory nor even upload to database here is my code , everything else uploads except the image <?php include('../connect.php'); if(isset($_POST['submit'])){ echo $post_title=mysqli_real_escape_string($connect,$_POST['title']); echo $post_date=date('m-d-y'); echo $post_price=mysqli_real_escape_string($connect,$_POST['price']); echo $post_keywords=mysqli_real_escape_string($connect,$_POST['keywords']); echo $post_content=mysqli_real_escape_string($connect,$_POST['content']); echo $post_image=mysqli_real_escape_string($connect,$_FILES['image']['name']); echo $image_tmp=mysqli_real_escape_string($connect,$_FILES['image']['tmp_name']); if($post_title=='' OR $post_price=='' OR $post_content=='' OR $post_keywords=='' OR $post_image=''){ echo "<script> alert('None of the post fields can be left blank')</script>"; }else{ //moves uploaded image into the image file move_uploaded_file($image_tmp,"../images/$post_image"); $insert_query="INSERT INTO posts (post_title,post_date,post_price,post_image,post_keywords,post_content) VALUES('$post_title','$post_date','$post_price','$post_image','$post_keywords','$post_content')"; if(mysqli_query($connect,$insert_query)){ echo "<script>alert('Succefully posted'); </script>"; } else "<h1> Did not work </h1>"; } if (is_uploaded_file($_FILES['image']['tmp_name'])) { echo "uploaded"; }else echo "could not upload"; var_dump(getcwd()); echo "<a href='logout.php'> Log out </a> <br/>"; echo "<a href='view_posts.php'> View Posts </a>"; ?> <?php } ; ?> here is the html <html> <head> <title> inserting new posts </title> <link rel="stylesheet" type="text/css" href="admin_style.css"> </head> <body> <div id="edit_postform"> <form method="post" action="insert_post.php" enctype="multipart/form-data"> <table width="600" align="centre" border"10"> <tr> <td> <h1> Insert New Post here </h1> </td> </tr> <tr> <td> Post title <td> <td> <input type="text" name="title" size="30"> </td> </tr> <tr> <td> Post Price<td> <td> <input type="text" name="price" size="30"> </td> </tr> <tr> <td> Post keywords<td> <td> <input type="text" name="keywords" size="30"> </td> </tr> <tr> <td> Post image <td> <td> <input type="file" name="image"> </td> </tr> <tr> <td> Post Content <td> <td> <textarea name="content" cols="20" rows="20" size="30"> </textarea> </td> </tr> <tr> <td> <input type="submit" name="submit" value="Publish now"> </td> </tr> </table> </form> </div> </body> </html>
  22. hi, i want to display members banners on my site that i'm making from scracth.The banners urls will be retrieve from the mysql database.the site url will not be display on the site but when a visitor clicks the banner the site url will be taken from database and redirect the visitor to the member site.i don't want people to upload banners to folders because of satey reasons so instead they have to give me their banner urls.i want to have many members so i won't be able to check every banner and i don't want reciprocal banners because they can hurt the site if it has malware.i have another question can malware appear on site with just the banner url? or do people need to visit a member site to get malware or viruses?.thanks. echo "<a href=\" " . htmlentities(stripslashes(constant('MY_SITE_URL'))) . "/". "?Clicked=" . urlencode($row['MEMBERID']) . "\" target=\"_blank\"> <img src=\"".$row['MemberBannerUrl'] . "\" alt=\"banner\" border=\"0\" height=\"60\" width=\"468\"></a>";
  23. The following code is what my team uses on our site to allow members to sign up for an account. The person that wrote it is no longer with us. One of the I'm having is im getting people with usernames like ""; show tables; --". I would like to disallow every character except a-z, numbers, _ , and -. Is this possible? The second problem I'm having is that users are no longer able to sign up... they get the error: Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home4/teamct/public_html/join/join-request.php on line 49 It failed. The other problem that existed while the registration still worked is that if the username already existed they get: Fatal error: Call to undefined function mysqli_exit() in /home4/teamct/public_html/join/join-request.php on line 63 If I delete line 63 then the page refreshes without informing the user that anything went wrong. I would like it to say something like "Sorry that username already exists. I have attached the entire join-request file (with usernames/passwords changed for security) Any help would be appreciated, let me know if you need anything else. UPDATE: The registration randomly works again O_o join-request.php
  24. I got a new pc. Copy my whole wamp server directory to an external. I have installed wamp on my new pc. When i copied the old data to the new pc directory no tables are showing, only the database name. I copied it into wamp/bin/mysql/mysql5.6.12/data/database. Can anybody assist me please
  25. Good day Can somebody help me with a link or some sort of code. I want a person to pay an amount into my bank account when the person register to be a member. So the person will type in his credit card details and then an amount will be paid. Thank you
  • 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.