Jump to content

Search the Community

Showing results for tags 'php mysql'.



More search options

  • 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 (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

    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

Found 5 results

  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, 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);
  3. 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>"; } ?>
  4. 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 !
  5. Can somebody maybe tell me is there an easier way to create the look of the website the html part. For example here is my code <html> <head> <title> Registration Form </title> </head> <body> <form method='post' action='registration.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Registration Form</h1></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' /></td> </tr> <tr> <td>Company Name:</td> <td><input type='text' name='company' /></td> </tr> <tr> <td>Registration Number:</td> <td><input type='text' name='reg_nr' /></td> </tr> <tr> <td>Telephone Number:</td> <td><input type='text' name='telephone' /></td> </tr> <tr> <td>Address:</td> </tr> <tr> <td>Street:</td> <td><input type='text' name='street' /></td> </tr> <tr> <td>Suburb:</td> <td><input type='text' name='suburb' /></td> </tr> <tr> <td>City:</td> <td><input type='text' name='city' /></td> </tr> <tr> <td>Province:</td> <td><input type='text' name='province' /></td> </tr> <tr> <td>Postal Code:</td> <td><input type='text' name='postalcode' /></td> </tr> <tr> <td>Contact Person:</td> <td><input type='text' name='contact_person' /></td> </tr> <tr> <td>Contact Person Telephone Number:</td> <td><input type='text' name='contact_person_tel' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='submit' value='Sign Up' /></td> </tr> </table> </form> <center><b>Already Registered</b><br><a href= 'login.php'>Login Here</a></center> </body> </html> <?php mysql_connect("localhost","root",""); mysql_select_db("whodidntpay"); if(isset($_POST['submit'])) { $com_password = $_POST['password']; $com_email = $_POST['email']; $com_companyname = $_POST['company']; $com_registration = $_POST['reg_nr']; $com_telephone = $_POST['telephone']; $com_street = $_POST['street']; $com_suburb = $_POST['suburb']; $com_city = $_POST['city']; $com_province = $_POST['province']; $com_postalcode = $_POST['postalcode']; $com_contactperson = $_POST['contact_person']; $com_contactpersontel = $_POST['contact_person_tel']; if($com_email=='') { echo "<script>alert('Please Enter Email')</script>"; exit(); } if($com_password=='') { echo "<script>alert('Please Enter Password')</script>"; exit(); } if($com_companyname=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } if($com_registration=='') { echo "<script>alert('Please Enter Registration Number')</script>"; exit(); } if($com_telephone=='') { echo "<script>alert('Please Enter Telephone Number')</script>"; exit(); } if($com_street=='') { echo "<script>alert('Please Enter Street Name')</script>"; exit(); } if($com_suburb=='') { echo "<script>alert('Please Enter Suburb Name')</script>"; exit(); } if($com_city=='') { echo "<script>alert('Please Enter City')</script>"; exit(); } if($com_province=='') { echo "<script>alert('Please Enter Province')</script>"; exit(); } if($com_postalcode=='') { echo "<script>alert('Please Enter Postel Code')</script>"; exit(); } if($com_contactperson=='') { echo "<script>alert('Please Enter Contact Person Name')</script>"; exit(); } if($com_contactpersontel=='') { echo "<script>alert('Please Enter Contact Person Telphone Nr')</script>"; exit(); } $check_email = "select * from complainant where email='$com_email'"; $run = mysql_query($check_email); if(mysql_num_rows($run)>0) { echo"<script>alert('Email $com_email already exists, please use another email')</script>"; exit(); } $query = "insert into complainant(email,password,company_name,registration_nr,telephone_nr,street,suburb,city,province,postal_code,contact_person,contact_person_tel) values ('$com_email','$com_password','$com_companyname','$com_registration','$com_telephone','$com_street','$com_suburb','$com_city','$com_province','$com_postalcode','$com_contactperson','$com_contactpersontel')"; if (mysql_query($query)) { echo "<script>alert('Registration Successful')</script>"; echo "<script>window.open('welcome.php','_self')</script>"; } } ?> Is there any way to create the html part with software and then just add the php part. Because doing it like this it is difficult for me to create a webpage that looks good.
×
×
  • 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.