[Solved] How to get search result by a keyword from different table in MySQL for php? [closed]

Maybe something like this? SELECT p.title, p.model_no, b.brand_name, c.category_title, s.specification_title FROM tbl_product AS p LEFT JOIN tbl_brand AS b ON b.id = p.brand_id LEFT JOIN tbl_category AS c ON c.id = p.category_id LEFT JOIN tbl_product_specification AS s ON s.product_id = p.id WHERE p.title LIKE ‘keyword’ OR p.model_no LIKE ‘keyword’ OR b.brand_name LIKE ‘keyword’ OR c.category_title … Read more

[Solved] How do I restrict special characters except underscore, hyphen and dot in email field in PHP? [duplicate]

Use a RegEx like this: /^[\w\.]+@/ Then you should also check if the domain really exists. PHP: $regex = “/^[\w\.]+@/”; $email = emailField($_POST[’email’]); $domain = preg_replace($regex, ”, $email); //get the domain of the email address by removing the local-part //Using checkdnsrr we are checking if this domain is registred if($email == ” && preg_match($regex, $email) … Read more

[Solved] PHP and MySQL are related to each other? [closed]

PHP is a programming language that’s primarily used for server-side web programming. MySQL is a relational database. The reasons you see them used together are as follows: Both are free and open-source Both are widely available on most web hosts (even shared hosting providers) PHP is used to create dynamic web pages, while MySQL is … Read more

[Solved] PHP check for existing entry in database [closed]

Use PDO like this, PDO and mysql_* functions not working together, you have to use them separately $sth = $dbh->prepare(‘SELECT COUNT(username) FROM users WHERE username= :username GROUP BY username’); $sth->bindParam(‘:username’, $username, PDO::PARAM_STR); $sth->execute(); if ($sth->fetchColumn() > 0) { echo “username taken”; } 2 solved PHP check for existing entry in database [closed]

[Solved] PHP cant connect to MySql (MySqli)

<?php $sql = new mysqli(‘127.0.0.1′,’root’,’Qwert12345′,’plot_io_db’); //echo $sql->query(‘Select * From players’); ?> It will work. Just remove port from localhost (127.0.0.1) 0 solved PHP cant connect to MySql (MySqli)

[Solved] Uploading a file to Google Signed URL with PHP cURL

this is what you want: remove CURLOPT_POSTFIELDS altogether, and replace CURLOPT_CUSTOMREQUEST=>’PUT’ with CURLOPT_UPLOAD=>1 and replace ‘r’ with ‘rb’, and use CURLOPT_INFILE (you’re supposed to use INFILE instead of POSTFIELDS), $fp = fopen($_FILES[‘file’][‘tmp_name’], “rb”); curl_setopt_array($ch,array( CURLOPT_UPLOAD=>1, CURLOPT_INFILE=>$fp, CURLOPT_INFILESIZE=>$_FILES[‘file’][‘size’] )); This works when I had $file = fopen($temp_name, ‘r’); never use the r mode, always use the … Read more

[Solved] Best way to echo variable in PHP [closed]

I don’t think you need 3 queries. One should be fine selecting both values. Queries 2 & 3 are identical anyway. $result1 = mysqli_query($con,”SELECT company_id, closed_state FROM tbl_company WHERE company_id=’$company_id'”) or die(mysql_error()); while($row = mysqli_fetch_array($result1)){ if ($row[‘closed_state’] == “yes”){ echo ‘<a href=”https://stackoverflow.com/questions/30514499/customers_open.php?company_id=”.$row[‘company_id’].'”>Reopen account</a>’; }else{ echo ‘<a href=”customers_close.php?company_id=’.$row[‘company_id’].'”>Close account</a>’; } } 1 solved Best way to … Read more

[Solved] Total number members in a group [closed]

Execute below code that will help you. $arr_ids = array(array(‘id’=>10,’group’=> ‘1’), array(‘id’=>20,’group’=> ‘1’), array(‘id’=>30,’group’=> ‘2’), array(‘id’=>40,’group’=> ‘3’), array(‘id’=>50,’group’=> ‘3’), array(‘id’=>60,’group’=> ‘3’), array(‘id’=>70,’group’=> ‘4’), ); foreach($arr_ids as $ids) { $arr_groups[] = $ids[‘group’]; } $count_arr = array_count_values($arr_groups); print”<pre>”; print_r($arr_groups); print_r($count_arr); foreach($count_arr as $group=>$count) { echo “Group “.$group.” = “.$count.”<br>”; } print”</pre>”; 1 solved Total number members in … Read more

[Solved] without indicate field name in PHP using MySQL get all data [closed]

Use mysql_fetch_row, then you can use $row_data[0] etc. while ($row_data = mysql_fetch_row($res_data)) { $html .= ‘<tr>’; for($i = 0; $i < count($row_data); $i++) { $html .='<td>’.$row_data[$i].'</td>’; } $html .= ‘</tr>’; } Please note that you should not combine this with SELECT * as any changes to the column order would break your code. 8 solved … Read more