
bbram
Members-
Posts
24 -
Joined
-
Last visited
Everything posted by bbram
-
you are correct...I totally forgot that and have fixed my code to have that and to display error messages...thank you for the help!
-
I am finally making the upgrade from PHP 5.3 to PHP 7.3. When converting over the code I noticed that session some sessions are not being processed. My test code for this is below: session_start(); include ("../includes/connect.inc"); echo "hiiiiiiii: ".$currentDate; echo "Here: ".$_SESSION['user']; if (isset($_SESSION['user'])) { $user = $_SESSION['user']; $currentDate = date("Y/m/d"); } else { echo "Session not started: "; } My include is listed below: $link = mysqli_connect('localhost', 'root', ''); if (!$link) { die('Could not connect: ' . mysql_error("Connection error message")); } mysqli_select_db($link, 'dbname') or die (mysqli_error($link)); date_default_timezone_set('America/Chicago'); define ("TZ_CORRECTION", 43200); $bkcolor = "#FFFFFF"; $currentDate = (Date("Y-m-d")); I am not getting the message "Session not started or the current date from the include". If it matters I am using WAMP as my testing server Any help is greatly appreciated.
-
Joins in general are still hard for me to figure out, and I don’t know why. I have the following code in my PHPMyAdmin console, and keep getting an error message: select DISTINCT login.username, login.login_time, players.Player_ID, players.Player_name, players.Player_First_Name, Players.Player_Last_Name, players.player_email INNER JOIN players on login.username=players.Player_ID where login.login_time > ‘2019-09-09’ Basically I am trying to figure out the last people that have logged in to our system within the past year and then will max it out to a certain number like 1000, or 500 depending on what mail server we use. Any help is greatly appreciated.
-
Ok I saw what you meant...I added <?php to the front and was getting an error message. I apparently changed my DB name sometime and forgot to update code. Thanks for helping with this.
-
I changed the file name to connect.php I do have <? and ?> in my connect file I also changed to use the following require 'includes/connect.php'; I also added echo $server and my page is telling me that i have an undefined error Still I am not sure what the problem is
-
I have a very simple page, where I use the include statement that includes my connection string. The connection string and a variables are not being passed to my test server - (WAMP). My include file is below $server = "servername"; $username = "username"; $password = ""; $database = "dbname"; $portNumber = 3308; $link = mysqli_connect($server,$username,$password,$database,$portNumber); if(!$link) { echo "cannot connet to the server"; } else { echo "This works"; } echo "Hi"; I am including this file with the following code: include ("includes/connect.inc"); My site is not connecting to the database, and is not displaying "This works", or "Hi". Do you have any pointers on how to get this connect?
-
I have 2 pages...1 one that has something like 500 checkboxes that list all of the active users in a database. When any number of checkboxes are selected it passes the variables from the checkboxes to the next page, asking for confirmation. Right now I have the 2nd page displaying numbers for the people, but doesn't display the correct entries. The code is below, hopefully it helps: if(isset($_POST['Update'])) //if the update button was pressed { if (isset($_POST['Player_number'])) //checks to see if any checkboxes are selected { //$Player_number = IMPLODE(',',$_POST['Player_number']); //putting the comma in between the array items echo $Player_number; ?> <input type="hidden" name="<?PHP $Player_number; ?>" value="<?PHP $Player_number; ?>"> $Player_number = IMPLODE(',',$_POST['Player_number']); //putting the comma in between the array items $result = mysql_query("SELECT * FROM `players` WHERE `Player_number` = '$Player_number' ORDER BY Player_Last_Name") or die(mysql_error()); while ($row = mysql_fetch_array($result)) //while ($row = mysql_fetch_assoc($result)) { // here is your data echo "FName: ".$row['Player_First_Name']; echo "lName: ".$row['Player_Last_Name']; echo "email: ".$row['player_email']; } foreach($_POST['Player_number'] as $row) { $result = mysql_query("SELECT `Player_First_Name`,`Player_Last_Name`,`player_email`, `Player_number` FROM `players` WHERE `Player_number` = '$Player_number' ORDER BY Player_Last_Name") or die(mysql_error()); $Player_number = IMPLODE(',',$_POST['Player_number']); //putting the comma in between the array items while($rows=mysql_fetch_array($result)) { echo "Player Number: ".$Player_number; //echo "pNumber: ".$row; //echo $rows['Player_First_Name']; ?> <tr bgcolor='<?PHP echo $bkcolor; ?>'> <td width = '20%' height="20"><div align="center"><input type="hidden" name="Player_number[]" value="<?php echo $row; ?>"></div></td> <td width= '20%' headers="20"><div align="center"><?php echo $rows['Player_First_Name']; ?></div></td> <td width= '20%' headers="20"><div align="center"><?php echo $rows['Player_Last_Name']; ?></div></td> <td width= '20%' headers="20"><div align="center"><?php echo $rows['player_email']; ?></div></td> <?PHP }//close of the while loop }//close of the foreach loop }//close of if (isset($_POST['Player_number'])) } //close of (isset($_POST['Update'] My issue that it goes through the For loop that is listed above, but list the player first name X amount of times.
- 1 reply
-
- whileloop
- foreach loop
-
(and 1 more)
Tagged with:
-
I have the following code $ifNameAlreadyExsist = "[0-9]"; //echo $newUserName[0-9]; echo $testUserName = $ifNewUserName[$ifNameAlreadyExsist]+; When I run the code I get the following error Parse error: syntax error, unexpected ';' in C:\wamp\www\new_signup.php on line if I have the following line of code $ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '$newUserName[0-9]'"; I get the following error: Parse error: syntax error, unexpected '-', expecting ']' in C:\wamp\www\new_signup.php on line 138 Can someone help me to figure out why I am getting the error messages listed above?
-
suggestions on how to write this code better I have a form that has 2 textboxes in it. The php listed below...confirms that the passwords match, confirms that there are at least 6 characters in in, confirms that there is at least 1 number. I am doing mostly if statements with it, but I was wondering if there was a better way to write. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form name="form1" method="post" action="<?PHP $_SERVER['PHP_SELF'] ?>"> <table width="100%" border="1"> <tr> <th scope="row"> <strong>New password: </strong> <input type="password" maxlength="15" name="password"></th> <th scope="row"> <strong>New password confirmed: </strong> <input type="password" maxlength="15" name="confirm_password"></th> <th scope="row"><input type="submit" name="update" value="Update Password" /></th> </tr> </table> </form> <?PHP //verify that the update button is pressed if (isset($_POST['update'])) { //verify that the passwords match if($_POST['password'] == $_POST['confirm_password']) { echo "passwords match"; echo "<br>"; } //verify that the password and password confirmation was entered elseif ((isset($_POST['password'])) && ($_POST['confirm_password'])) { echo "Password and confirm password set"; echo "<br>"; } //verify that the # of characters was entered elseif (strlen($_POST['password'])<6) { $num_char=strlen($_POST['password']); echo "Please enter more characters"; echo "<br>"; } //find out if number exsist if (strlen($_POST['password'])>5) { $subject = $_POST['password']; preg_match_all('/[0-9]/', $subject, $matches); $count = count($matches[0]); //echo $count; if ($count <=1) echo "Please enter in at least 1 number you currently have: " .$count; }//close of verification of both boxes entered }//close of $_POST ?> </body> </html>
-
Can't you do it like this if (isset$_post['textboxname'] { do something } else { redirect back to main page }
-
Okay I got it fixed thanks for your help... Now my query is not displaying any information... $countPlayers=mysql_query("SELECT players.Player_number, players.Player_name FROM players WHERE ((NOT Inactive_player) AND ((players.Player_Last_Name = '$player_find%'))) ORDER BY Player_name"); $row = mysql_fetch_assoc($countPlayers) or die("No rows returned by query"); echo $row['Player_number'];
-
Hello I have the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM players WHERE ((NOT inactive_player) AND ((players.Player_Last_Name = 'p' at line 3 I think my error is in the statement below... echo "1"; $getNewPlayers = "SELECT players.Player_number, players.Player_name, FROM players WHERE ((NOT inactive_player) AND ((players.Player_Last_Name = 'player_find%'))) ORDER BY player_name"; $rsNewPlayers = mysql_query($getNewPlayers, $link) or die (mysql_error()); $varNewCount = mysql_num_rows($rsNewPlayers); echo $varNewCount['Player_name']; Can you tell me where the error is and how I might go about to fix it? Thanks,
-
I know this probably not it...but you are missing closing ) on the if statement.
-
<?PHP session_start(); if (isset($_SESSION['user'])) { $user = $_SESSION['user']; $password = $_SESSION['password']; } else { //if the username is not passed then it goes back to the login page header("location: /player_login.php"); } $link = mysql_connect('localhost', 'root', ''); echo $user; echo $password; if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("movedb")or die("Cannot Select Database"); //gets the current player number for the person logged in $checkquery = "Select player_number from players where Player_ID = '$user'"; $checkresults = mysql_query($checkquery) or die (mysql_error()); //select the rung number for the singles ladder $checksingles = "Select rung_number from doubles_ladder where player_number = '$user'"; $checkifsingles = mysql_query($checksingles) or die (mysql_error()); $checkplayernumber = "Select player_number from security where userid = '$user' AND password = '$password'"; $getplayernumber = mysql_query($checkplayernumber) or die (mysql_error()); $ssPlayerNumber=mysql_fetch_assoc($getplayernumber); $query = "SELECT MAX(paid_thru) FROM players_paid where paid_type = '1' AND player_number = '{$ssPlayerNumber['player_number']}'"; $result = mysql_query($query)or die ('Error in query: $query. ' . mysql_error()); $row = mysql_fetch_assoc($result); $max = $row['MAX(paid_thru)']; //converts the date to a more readable format $max = $row['MAX(paid_thru)'] = date("M d, Y",strtotime($row['MAX(paid_thru)'])); echo "Ladder Membership Recently Expired on : " .$max. "!!!"; $rsSingles = "SELECT match_results_singles.match_date AS match_date, match_results_singles.match_time, match_results_singles.match_result, match_results_singles.home_sets_won as my_wins, match_results_singles.visitor_sets_won as my_losses, locations.loc_name, players.Player_name, ' ' as supplies_balls FROM (match_results_singles INNER JOIN players ON match_results_singles.match_visiting_player = players.Player_number) INNER JOIN locations ON match_results_singles.match_location = locations.loc_code WHERE (((match_results_singles.match_home_player)='{$ssPlayerNumber['player_number']}' )) UNION SELECT match_results_singles.match_date AS match_date, match_results_singles.match_time, match_results_singles.match_result, match_results_singles.visitor_sets_won as my_wins, match_results_singles.home_sets_won as my_losses, locations.loc_name, players.Player_name, '*' as supplies_balls FROM (match_results_singles INNER JOIN players ON match_results_singles.match_home_player = players.Player_number) INNER JOIN locations ON match_results_singles.match_location = locations.loc_code WHERE (((match_results_singles.match_visiting_player)='{$ssPlayerNumber['player_number']}' )) ORDER BY match_date"; $rsSinglesMatch = mysql_query($rsSingles) or die (mysql_error()); $rsSinglesMatches = mysql_fetch_array($rsSinglesMatch); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?PHP while($rows=mysql_fetch_array($checkresults)) { echo $rows['player_number'] ; } $num_rows = mysql_num_rows($rsSinglesMatch); //$num_rows now contains the number of rows from the query echo $num_rows; if ($num_rows > 0 ) { echo $ssPlayerNumber; echo ("YEX"); } else { echo "ROWS"; } $myrow = mysql_fetch_row($rsSinglesMatch); //$rsSinglesMatches = mysql_fetch_assoc($rsSinglesMatch); print_r($myrow); // if (!($rsSinglesMatches==0) || !($rsSinglesMatches_BOF==1)) if ($myrow > 0) { echo $myrow; } else { echo "Rows not counted: "; } ?> <br> </body> </html> Sorry for the goof up...I just saw you wanted from query on... Everything else seems to work except for the count of rows....
-
Okay thanks for your help.... The rest of the page is as follows: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?PHP while($rows=mysql_fetch_array($checkresults)) { echo $rows['player_number'] ; } $num_rows = mysql_num_rows($rsSinglesMatch); //$num_rows now contains the number of rows from the query echo $num_rows; if ($num_rows > 0 ) { echo $ssPlayerNumber; echo ("YEX"); } else { echo "ROWS"; } $myrow = mysql_fetch_row($rsSinglesMatch); //$rsSinglesMatches = mysql_fetch_assoc($rsSinglesMatch); print_r($myrow); // if (!($rsSinglesMatches==0) || !($rsSinglesMatches_BOF==1)) if ($myrow > 0) { echo $myrow; } else { echo "Rows not counted: "; } ?> <br> </body> </html>
-
I have a query.... $rsSingles = "SELECT Count(match_results_singles.match_date AS match_date, match_results_singles.match_time, match_results_singles.match_result, match_results_singles.home_sets_won as my_wins, match_results_singles.visitor_sets_won as my_losses, locations.loc_name, players.Player_name, ' ' as supplies_balls FROM (match_results_singles INNER JOIN players ON match_results_singles.match_visiting_player = players.Player_number) INNER JOIN locations ON match_results_singles.match_location = locations.loc_code WHERE (((match_results_singles.match_home_player)='{$ssPlayerNumber['player_number']}' )) UNION SELECT match_results_singles.match_date AS match_date, match_results_singles.match_time, match_results_singles.match_result, match_results_singles.visitor_sets_won as my_wins, match_results_singles.home_sets_won as my_losses, locations.loc_name, players.Player_name, '*' as supplies_balls FROM (match_results_singles INNER JOIN players ON match_results_singles.match_home_player = players.Player_number) INNER JOIN locations ON match_results_singles.match_location = locations.loc_code WHERE (((match_results_singles.match_visiting_player)='{$ssPlayerNumber['player_number']}' )) ORDER BY match_date)"; $rsSinglesMatch = mysql_query($rsSingles) or die (mysql_error()); $rsSinglesMatches = mysql_fetch_array($rsSinglesMatch); sorry I forgot to post that earlier.
-
I have the following code... $num_rows = mysql_num_rows($rsSinglesMatch); //$num_rows now contains the number of rows from the query echo $num_rows; if ($num_rows > 0 ) { echo $ssPlayerNumber; echo ("YEX"); } else { echo "ROWS"; } $myrow = mysql_fetch_row($rsSinglesMatch); //$rsSinglesMatches = mysql_fetch_assoc($rsSinglesMatch); print_r($myrow); // if (!($rsSinglesMatches==0) || !($rsSinglesMatches_BOF==1)) if ($myrow > 0) { echo $myrow; } else { echo "Rows not counted: "; } And I can't get the mysql_num_rows and mysql_fetch_rows to work. Currently it displays Rows not counted: and ROWS if I ask it to display the number of rows it shows it as being 0. Let me know if you see anything or if I need to post anything else.
-
Hello I am prewriting my sql statements in the php myadmin that I currently have. I will then be inserting them into php after I get them all written. But I am getting a an error...Unknown column 'player_number.doubles_ladder' in 'field list' The sql statement that I have is as follows: SELECT rungs.rung_number, player_number.doubles_ladder, player_number2.doubles_ladder FROM rungs FULL JOIN rungs ON doubles_ladder.rung_number=rungs.rung_number ORDER BY rungs.rung_name Although I know I have player_number inside my doubles_ladder table. [/code]
-
Hello I am getting an error in my php code. I think the error is in the first line of code but I am not 100% for sure. The error states... Notice: Undefined index: paid_date ... Can you tell me if I am going down the correct route to select the max date in a column? [b]$query = "Select MAX(paid_date) as paidDate from players INNER JOIN players_paid ON players.player_number=players_paid.player_number"; $query = mysql_query($query) or die(mysql_error());[/b] /*SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name*/ //echo "SELECT 1 FROM players_paid WHERE (((players_paid.player_number)="+str_replace("'","''",$rsNewPlayer__ssPlayerNumber)+") AND ((players_paid.paid_type)=1))"; ?> <html> <body> <?PHP echo $user; ?> <br> <?php echo $password; ?> <br> <?PHP while($rows=mysql_fetch_assoc($query)) { ?> <table width="100%" border="1"> <tr> <th scope="col"><?PHP echo $rows['paid_date'] ?></th> </tr> </table> <?PHP } ?> </body> </html>
-
Why a Parse error: syntax error, unexpected T_STRING
bbram replied to bbram's topic in PHP Coding Help
I see that I am missing the mysql_query at the beginning of the $sql but you explain to tell me what is wrong with the <? echo .rows[faq_subject]. ?> -
I am getting the following error: Why a Parse error: syntax error, unexpected T_STRING on line 16. Line 16 is my sql statement and I don't know why it is has an unexpected T_string. Can you possibly help and let me know what I did wrong? <?PHP $link = mysql_connect('localhost', 'root', ''); if (!$link) { //if no connection then display error die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('movedb', $link); if (!$db_selected) { die ('Can\'t use movedb : ' . mysql_error()); } $sql= ("SELECT * FROM faq_table ORDER BY faq_subject_rank, faq_priority") or (die mysql_error()); ?> <html> <head> <title>FAQ page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="/atn.css" type="text/css"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?PHP while($rows=mysql_fetch_array($sql)) { ?> <tr> <td width="15%" height="30" colspan="2"> </td> <td width="70%" height="30"> <div align="center"><font size="3" face="Arial, Helvetica, sans-serif"><strong><em><? echo .rows[faq_subject]. ?></em></strong></font></div></td> </tr> <?php } ?> </table> </body> </html>
-
Hello I am getting the following errors when I am running the code below. I am not 100% for sure what the error's mean. If possible can you guide help to figure out what is wrong with my code? Notice: Undefined index: Userid in C:\wamp\www\checklogin.php on line 13 Notice: Undefined index: password in C:\wamp\www\checklogin.php on line 14 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\checklogin.php on line 26 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\checklogin.php on line 29 <?php $host="localhost"; $username="root"; $password=""; $db_name="movedb"; $tbl_name="security"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("Cannot Select Database"); // username and password sent from form $myusername=$_POST['Userid']; $mypassword=$_POST['password']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); //this creates an array with the results $row= mysql_fetch_array($result); echo ("HI"); //this gets the value held in the 'user_level' column for the user //$user_level = $row['user_level']; if($count==1) { echo ("passed"); echo $myusername; echo $mypassword; /* // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword");*/ header("location:login_success.php"); } else { echo ("failed"); echo $myusername; echo $mypassword; //header("location:access_denied.php"); } /*else { echo "Wrong Username or Password"; }*/ ?>