Search the Community
Showing results for tags 'php mysql'.
-
Hi guys, please what am i doing wrong here? i have searched almost everywhere on the internet and found solutions similar to my own but they are not just working!! i am sorry if this question has been asked before. i'm not getting things right. the project is actually a very complex one. i have used many methods but all to no avail. Please help! I have two tables called "group_profile" and "group_members". The concept is that users have already created their groups. Then these groups have been stored into my database table. And now i want to retrieve the records from that table and display it on the "join_group.php" page so that that people can click to join those groups selected from the first table. Users can select multiple groups to join using checkboxes at a time. Therefore, when you join the group, the script will add both your data and the groups' to "group_members" table but if i select multiple groups and click on join button, it appears to add only the last group created in the "group_profile" table. Sometimes it will take me to the "processing-join-group.php" page and show me the script doesn't seem to work well. i'm sure there is something i'm doing wrong. Please here is my code so far: This is the "join_group.php" page below: <?php $other_following_account = mysqli_query($f->connectTo(), "SELECT * FROM group_profile"); if ($f->numR($other_following_account) > 0) { while($show_created_groups = $f->show_data($other_following_account)) { $select_member = $f->andFilterRecord("*", "hoollaa_group_members", "user_id", $_id, "group_id", $show_created_groups['id']); $chk_user_id = $f->show_data($select_member); $check_my_membership = $f->numR($select_member); if (!$check_my_membership) { if ($show_created_groups['user_id'] != $_id) { ?> <div class="inner-main-cont-left main-cont-right box-shadow" style="height: 370px; width: 250px;"> <?php if ( empty($show_created_groups['group_photo2']) ) { ?> <span class="container"> <span class="profile-avatar2"><?php echo substr($show_created_groups['group_name'], 0, 1);?></span> </span> <?php } else { ?> <img style="margin-bottom: -5px;" src="<?php echo $show_created_groups['group_photo2'];?>" /> <?php } ?> <div class="profile-content" style="padding: 10px 8px 10px 10px; height: 80px;"> <div class="main-cont-left-header-profile"><?php echo $show_created_groups['group_name'];?></div> <div class="clear-left"></div> <p style="word-wrap: break-word;"> <?php $d_string = $show_created_groups['group_description']; $new_str = (strlen($d_string) > 63) ? trim(substr($d_string, 0, 60))."..." : $d_string; echo $new_str; ?> </p> </div> <input name="admin_id[]" type="" value="<?php echo $show_created_groups['user_id']; ?>" /> <input name="group_name[]" type="" value="<?php echo $show_created_groups['group_name']; ?>" /> <input name="group_admin[]" type="" value="<?php echo $show_created_groups['group_admin']; ?>" /> <input name="group_id[]" type="" value="<?php echo $show_created_groups['id']; ?>" /> <input type="checkbox" name="join_data[]" value="<?php echo $show_created_groups['id']; ?>" id='c<?php echo $show_created_groups['id'];?>[]' class='chk-btn' /> <label style="padding: 10px; margin: 60px 0px 0px 178px;" for='c<?php echo $show_created_groups['id'];?>[]'>Join</label> </div> <?php } } } } ?> <div class="clear-left"></div> </div> <button class="skip-btn floating-nav-btn btn btn__trigger btn__trigger--views" name="join_btn" type="submit"> <i class="fa fa-caret-right" style="font-size: 32px;"></i> </button> </form> And here is the page that is receiving the data from "join_group.php" processing-join-group.php" page: <?php require_once "../set-header-dependencies.php"; /* $f->isUserLoggedIn_sess("auth", "../home.php"); $f->isUserLoggedOut_sess("auth", "../index.php"); */ $time_zone = date_default_timezone_set("Africa/Lagos"); $date_published = date("F d, Y"); $time_published = date("H:i:sa"); $time_stamp = time(); //Follow Selected group if (isset($_POST['join_btn'])) { if (isset($_POST['join_data'])) { $display_follow_data = $f->post_data('join_data'); if (is_array($display_follow_data)) { foreach ($display_follow_data as $key => $array_id) { $select_store = $f->andFilterRecord("*", "group_members", "user_id", $_id, "group_id", $array_id); $chk_user_id = $f->show_data($select_store); $select_from_main_store = $f->filterRecord("*", "group_profile", "user_id", $array_id); while($use_selected_product = $f->show_data($select_from_main_store)) { $admin_id = $use_selected_product['user_id']; $group_name = $use_selected_product['group_name']; $group_admin = $use_selected_product['group_admin']; $group_id = $use_selected_product['id']; if ($use_selected_product['id'] != $chk_user_id['group_id']) { $insert_follow_data = "INSERT INTO group_members(group_name,group_id,admin_id,group_admin,username,user_id,timestamp,date_published,time_published) VALUES ('$group_name','$group_id','$admin_id','$group_admin','$acc_username','$_id','$time_stamp','$date_published','$time_published')"; $f->cts($insert_follow_data); $_SESSION['follow_success'] = "<script>$('body').tpPopup({avatar: 'hoollaa-icons/Notifications.png',username: '',message: 'Group joined.',openOnClick: 'join-groups.php'});</script>"; $f->rdr("../home.php"); } else { $_SESSION['follow_error'] = "<script>$('body').tpPopup({avatar: 'hoollaa-icons/Notifications.png',username: '',message: 'Could not add you to.',openOnClick: 'join-groups.php'});</script>"; $f->rdr("../home.php"); } } } } else { $_SESSION['follow_error'] = "<script>$('body').tpPopup({avatar: 'hoollaa-icons/Notifications.png',username: '',message: 'Please select a group to join.',openOnClick: 'join-groups.php'});</script>"; $f->rdr("../home.php"); } } else { $_SESSION['follow_error'] = "<script>$('body').tpPopup({avatar: 'hoollaa-icons/Notifications.png',username: '',message: 'Please select a group to join.',openOnClick: 'join-groups.php'});</script>"; $f->rdr("../home.php"); } } ?>
-
Hallo, what might mean this message of error: "Parse error: syntax error, unexpected end of file in /home/pavlinan/public_html/mes.php on line 22" Here is the code: <?php$email = $_POST["meil"];$message = $_POST["area"];$ime= $_POST["ime"];echo "From: ".$_POST["ime"]."<br>";echo "Email: ".$_POST["meil"]."<br>";echo $_POST["area"]."<br>";// Create connection$con=mysql_connect("localhost","pavlinan_db","mishon24");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("pavlinan_backform");mysql_query("INSERT INTO `backform` (`name` , `email` , `text` )VALUES (`$ime`, `@email`, `$message`)`,$con);mysql_close($con);?>
-
Here is one of the simplest routines I have written--right? No, wrong. The script takes a table, folds, spindles, and mutilates it, and writes the data back to the table. Here's the code: $Quest = "SELECT * FROM TOAWorkorders";$FindTechResult = mysql_query($Quest, $cxn) or die ('The easter bunny is watching you' . mysql_error());while ($row = mysql_fetch_array($FindTechResult)){ $IdNum = $row['IdNum']; $BBT = $row['BBT']; $BBTArray = explode("-", $BBT); $TechNum = $BBTArray["0"]; $Title = $BBTArray["2"]; $Name = explode(" ", $BBTArray['1']); $FirstName = $Name["0"]; $LastName = $Name["1"]; echo $TechNum . ' !! ' . $FirstName . ' !! ' . $LastName . ' !! ' . $Title . '<br>'; $Quest = "UPDATE TOAWorkorders SET TechNum = '$TechNum', FirstName = '$FirstName', LastName = '$LastName', Title = '$Title' WHERE IdNum = '$IdNum'";$result = mysql_query($Quest, $cxn) or die(mysql_error()); } The problem with the script is the `UPDATE` statement. The field is processed correctly, but the update only updates 2/3 of the table, leaving 33k of rows untouched. Any ideas??
-
Hi, I'm just starting out with php and mysql.I've successfully created my database, tables, php connection file, and forms to update records so all in all good start.My connection.php looks like this: <?php$db_host = "localhost";$db_username = "dummy";$db_pass = "dummy1234";$db_use = "dummy";$con = mysql_connect("$db_host","$db_username","$db_pass");if (!$con) { die('Could not connect to mysql: ' . mysql_error()); } echo "Connected to mysql";?><br /><?phpmysql_select_db("$db_use", $con);echo "Connected to database: "."$db_use";?> I'm trying to create a form that submits variables e.g. $db_host = $_POST['host'];$db_username = $_POST['username']; $db_pass = $_POST['pass']; $db_use = $_POST['db']; so that the user can open different databases on different hosts.But when the php form is parsed I receive the undefined index error due to the variables not being set initially (I think!).Can anyone offer any advice?