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


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. 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. 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
  3. 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"); } ?>
  4. 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?
  5. 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
  6. 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.
  7. 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
  8. 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
  9. 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
  10. 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()";
  11. 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>
  12. 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 = ""; } ?>
  13. 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?
  14. 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!
  15. 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
  16. One image is displaying but when i choose image 2 it overlaps image 1..gallery.php
  17. 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)
  18. 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>
  19. 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>";
  20. 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
  21. 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
  22. 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
  23. Can somebody maybe assist me. I am new to php mysql. Someone told me my html code is terrible. Here are some things they told me. You have table rows that aren't inside <table>..</table> tags You are not using end tags (such as </p>, </tr> The piece of code above should be inside the html <body>..</body> tags and not after the closing </html> tag. Can someone help me to fix these problems in my code please. Here is my code: <?php session_start(); ?> <!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> <title>Complaints</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">Complaints:</h2> <p> </p> <p> </p> <p> <form method="post" action="allcompanies.php?go" id="showallform"> <p> </p> <p> </p> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Complaints</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $comp = $_GET['comp']; $sql="SELECT complain FROM complaint c WHERE c.d_name = '" . mysql_real_escape_string($comp) . "'"; //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found </p>"; while($debtor=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$debtor['complain']."</td>"; echo "</tr>"; } echo "<br/><a href=\"companydetails.php?company=$comp\">See more details</a>"; echo "<tr>"; echo "<tr>"; mysql_close($db); ?>
  24. Can somebody help me. I have a table with a complaints column and in that there are display for each record details that you can click on and then a page must appear to show the details. Here is my code error : Undefined variable: comp in C:\wamp\www\whodidntpay\complaints.php on line 76 Here is my code: First all companies where the table is with the details option <?php session_start(); ?> <!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> <title>All Companies</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">All Companies:</h2> <p> </p> <p> </p> <p> <form method="post" action="allcompanies.php?go" id="showallform"> <p> </p> <p> </p> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Company Name</th> <th>Email</th> <th>Companies not Paid</th> <th>Amount not Paid</th> <th>Complaints</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $sql="SELECT d_name,email,companies_not_paid,amount_not_paid FROM debtor ORDER BY d_name"; //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found "; while($debtor=mysql_fetch_array($result)) { echo "<tr>"; echo "<td><a href=\"companydetails.php?company={$debtor['d_name']}\">{$debtor['d_name']}</a></td>"; //echo "<td>".$debtor['d_name']."</td>"; echo "<td>".$debtor['email']."</td>"; echo "<td>".$debtor['companies_not_paid']."</td>"; echo "<td>".$debtor['amount_not_paid']."</td>"; echo "<td><a href=\"complaints.php?comp={$debtor['d_name']}\">Details</a></td>"; } mysql_close($db); ?> Here is the complaints code where there must be referenced to <?php session_start(); ?> <!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> <title>Complaints</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">Complaints:</h2> <p> </p> <p> </p> <p> <form method="post" action="allcompanies.php?go" id="showallform"> <p> </p> <p> </p> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Complaints</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $sql="SELECT complain FROM complaint c WHERE c.d_name = '$comp' ";; //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found "; while($debtor=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$complaint['complain']."</td>"; } mysql_close($db); ?>
  25. Can somebody help me with this pagination. Got the tutorial on the internet, but are experiencing some problems. I want to display results per page. I think here is my error $data = mysql_query("SELECT * FROM topsite") or die(mysql_error()); but dont know what to change topsite to. Here is my code: <?php session_start(); ?> <!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> <title>Search</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">All Companies:</h2> <p> </p> <p> </p> <p> <form method="post" action="allcompanies.php?go" id="showallform"> <p> </p> <p> </p> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Company Name</th> <th>Email</th> <th>Companies not Paid</th> <th>Amount not Paid</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $sql="SELECT d_name,email,companies_not_paid,amount_not_paid FROM debtor ORDER BY d_name"; //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found "; while($debtor=mysql_fetch_array($result)) { echo "<tr>"; echo "<td><a href=\"companydetails.php?company={$debtor['d_name']}\">{$debtor['d_name']}</a></td>"; //echo "<td>".$debtor['d_name']."</td>"; echo "<td>".$debtor['email']."</td>"; echo "<td>".$debtor['companies_not_paid']."</td>"; echo "<td>".$debtor['amount_not_paid']."</td>"; } mysql_close($db); //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM topsite") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query("SELECT * FROM topsites $max") or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array( $data_p )) { Print $info['Name']; echo "<br>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?>
×
×
  • 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.