[Solved] PHP Session ID issue [closed]

You have one fundamental problem: if ( !isset( $_SESSION ) ) $_SESSION = null; if ( ( !is_array( $_SESSION ) ) xor ( !isset( $_SESSION[‘nzshpcrt_cart’] ) ) xor ( !$_SESSION ) ) session_start(); You can’t access the session before it is started. Try starting it and then accessing it… Also xor is a bitwise comparison…I’m … Read more

[Solved] Data inserting in mysql data base not working [closed]

response_id,participant_id,question_id,answer_option_answer_text vs (response_id,participant_id,question_id,answer_option) and your line ” $participant_id=$_POST[‘participant_id’] ” is missing its semicolon (;) also please use if( !mysql_query( $query, $con ) ) { echo(“Failure: ” . mysql_error() ); } to insert data. 2 solved Data inserting in mysql data base not working [closed]

[Solved] Get current seeder’s IP addresses of a torrent using PHP [closed]

There are two largely separate parts – querying the torrent tracker for the seeders IP, and reverse-geocoding the IP addresses to determine the country. The reverse-geocoding part is a common thing, and easily done. This question lists several options, and this one is similar, but specifically for PHP The torrent-tracker-querying part is a bit more … Read more

[Solved] How to construct sub arrays from a main array

You mean like this?: $array = array( array(‘id’ => 1, ‘status’ => -1), array(‘id’ => 2, ‘status’ => 1), array(‘id’ => 3, ‘status’ => 2), array(‘id’ => 4, ‘status’ => 2), array(‘id’ => 5, ‘status’ => 2) ); $statuses = array(); foreach($array as $one){ if(!isset($statuses[$one[‘status’]])){ $statuses[$one[‘status’]] = 0; } $statuses[$one[‘status’]]++; } $newArray = array(); foreach($statuses … Read more

[Solved] PHP is not executing in HTML [closed]

The colour of the code in your editor has no bearing on the result. In my editor, both “invalid HTML tag” and “PHP tag” are red(-ish), but that doesn’t mean they’re the same 😉 Now, as for your problem, you need to be running this on a server. Just loading the file in your browser … Read more

[Solved] Parse error: syntax error, unexpected ‘[‘, expecting ‘,’ or ‘;’ on line 30

It might be echo $users->pack_info($uinfo[‘package’][‘max_attack_time’]); instead of echo $users->pack_info($uinfo; [‘package’] )[‘max_attack_time’] edit assuming you are trying to do function array dereferencing (which requires php>=5.4) it might be echo $users->pack_info($uinfo[‘package’])[‘max_attack_time’]; solved Parse error: syntax error, unexpected ‘[‘, expecting ‘,’ or ‘;’ on line 30

[Solved] Error message: “Object not found! The requested URL was not found on this server.” [closed]

By default, xampp’s apache looks into c:\xampp\htdocs But you should have the habit to create virtual hosts for your projects. Open c:\xampp\apache\conf\extra\httpd-vhosts.conf, and place this into it: <VirtualHost *:80> DocumentRoot “C:/Eclipse/workspace/your-project/” ServerName your-project <Directory C:/Eclipse/workspace/your-project/> Order Allow,Deny Allow from 127.0.0.1 </Directory> </VirtualHost> Then open your hosts file and add your-project entry: 127.0.0.1 your-project Restart apache … Read more

[Solved] How to convert multiple if else in SWITCH case [closed]

I think there is no need to convert it into switch case, but you can simplify it like, <?php if($ridestatus == ‘Y’) { if($pass_status == ‘Y’ || $pass_status == ‘NR’) $status=”1″; elseif($pass_status == ‘RNS’) $status=”RNS”; } elseif($ridestatus == ‘RNS’) { if($pass_status!=”) $status=”RNS”; } elseif($ridestatus == ‘NR’) { if($pass_status==’Y’) $status=”1″; elseif($pass_status == ‘RNS’) $status=”RNS”; } else … Read more

[Solved] Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn’t match number of parameters in prepare [closed]

should be if ($insert_stmt = $mysqli->prepare(“INSERT INTO members (username, email, password, salt, privilegio) VALUES (?,?,?,?,?)”) { $insert_stmt->bind_param(‘sssss’, $username, $email, $password, $random_salt, $privilegio); // Execute the prepared query. $insert_stmt->execute(); } solved Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn’t match number of parameters in prepare [closed]

[Solved] MySQL INSERT statement brings an error [closed]

Order is reserved word in MySQL, you can use back tick(`) around table name Also you can use MySQL NOW() function for date instead of PHP variable $date $t = “INSERT INTO `order` (order_date) VALUES (NOW())”; solved MySQL INSERT statement brings an error [closed]

[Solved] I want to print age in my bill from dob. dob is stored in $_SESSION but its not printing the age in html page

<?php session_start(); ?> <?php $dob = $_SESSION[‘dob’]; ?> <html> <head> </head> <body> Age:<?php $from = new DateTime($dob); $to = new DateTime(‘today’); echo $from->diff($to)->y; ?> </body> </html> You didnt start the session on that page. And I changed new DateTime(‘$dob’) to new DateTime($dob) because is variable. 0 solved I want to print age in my bill … Read more

[Solved] Parsing XML from a Web Page with PHP [closed]

Your api returns json, you can decode it with json_decode, i have also include how to traverse through the json objects included in the feed. $json = file_get_contents(“http://api.roblox.com/users/3/friends”); $obj = json_decode($json); for ($i=0; $i < count($obj); $i++) { echo $obj[$i]->Id; echo $obj[$i]->Username; } 3 solved Parsing XML from a Web Page with PHP [closed]

[Solved] multiple row entry in phpmyadmin using for loop [closed]

Modify $roll_array[] and make it a string as follow: $roll_string = ”; for($i=$roll_number_start; $i<=$roll_number_end; $i++) { $roll_number = $roll_number_format.$i; $p_username = generatePassword(); $p_password = generatePassword(); $roll_string .= “(‘”.$roll_number.”‘,”.”‘”.$student_class.”‘,”.”‘”.$class_section.”‘,”.”‘”.$batch_year.”‘,”.”‘”.$p_username.”‘,”.”‘”.$p_password.”‘),” } $roll_string = substr($roll_string, 0, -1); $insert_sql = “INSERT INTO student (roll_number, student_class, class_section, batch_year, p_username, p_password) VALUES “.$roll_string; 4 solved multiple row entry in phpmyadmin using … Read more