Jump to content

acctman

Members
  • Posts

    582
  • Joined

  • Last visited

Everything posted by acctman

  1. thanks for all the tips ... I'm going to find a tutorial on mysqli to bring myself up to speed
  2. can someone assistance me with converting this code over to mysqli. I know that mysqli requires 2 parameters instead of one... i tried $user = mysqli_real_escape_string($g_link, $en['user']); but no connection was passed. $user = mysql_real_escape_string($en['user']); $pass = mysql_real_escape_string($en['pass']); $sql = "SELECT m_id, m_user, m_pass, m_email, m_del FROM $membtable WHERE m_user='".$user."' AND m_pass='".$pass."' AND m_del!=1"; $result = mysql_query($sql); $line = mysql_fetch_assoc($result); Db Connection $g_link = false; function GetDbConn() { global $g_link; if( $g_link ) return $g_link; $g_link = mysqli_connect($db_server, $db_user, $db_pass) or die("Error " . mysqli_error($g_link)); mysqli_select_db($g_link, 'cialdb') or die('Could not select database.'); return $g_link; }
  3. after re-reading your response I found the problem. I did not have the database in $con... the error checked worked.
  4. but I have if (mysqli_num_rows($loadSession) == 0) { to had if it's 0 (false). Am I missing something?
  5. I'm trying to resolve these to mysqli update changes. I've rewritten the statements a few times but just keep receiving errors. Can some show me how to rewrite the mysqli_result() correctly. - thanks Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in $loadSession = mysqli_query($con, "SELECT smo.* FROM social_members_online AS smo LEFT JOIN social_members AS sm ON smo.o_id=sm.m_id WHERE smo.o_id='".session_id()."' ...); $result = mysqli_fetch_assoc($loadSession); // Check the Result if (mysqli_num_rows($loadSession) == 0) { // User has no session, create one mysqli_query($con, "INSERT INTO social_members_online (o_id,o_start,o_last,o_session_id,o_ip) VALUES (".(int)$_SESSION['userid'].", ".time().",".time().",'".session_id()."','$ }
  6. can someone help me change this to preg_replace_callback. i'm receiving the following error Warning: preg_replace_callback(): Requires argument 2, '@constant("\1")', to be a valid callback in //load current language foreach ($langs as $key => $value) if ($value['l_code'] == lang) break; $f = fopen('languages/'.$langs[$key]['l_file'],'r') or die('Cannot open language file '.$langs[$key]['l_file']); while (!feof($f)) { $s = chop(fgets($f,4096)); if ($s{0} == '#') continue; list($key,$value) = explode('=',$s,2); $value = preg_replace('/<%(.*)%>/sUe', '@constant("\\1")', $value); $def[$key] = $value; } fclose($f);
  7. I'm trying to use htmlspecialchars() to escape apostrophe foreach(htmlspecialchars($_POST) as $key=>$val) { but it's not escaping / working. Am I placing it in the wrong place? thanks in advance if(isset($_POST['save_your_application']) || isset($_POST['save_progress'])) { $errors = 0; $detailsArray = array(); $insertArray = array(); foreach($_POST as $key=>$val) { $stringDivide = explode("_", $key); // Break up key name $type = end($stringDivide); // Get the TYPE of field $fullKey = $key; //$key = substr($key, 0, -4); // Get the field name (deleting the TYPE from the end) // IF FIELD IS A NUMBER if(strcmp($type, "num") == 0) { $array = array(); $array['key'] = $key; $array['value'] = (int)$val; if($val == "") $array['value'] = NULL; $array['type'] = $type; $insertArray[] = $array; } // IF FIELD IS TEXT elseif(strcmp($type, "txt") == 0) { $array = array(); $array['key'] = $key; $array['value'] = $val; $array['type'] = $type; $insertArray[] = $array; } $detailsArray[$fullKey] = $val; } if(isset($_POST['save_progress']) && $_POST['save_progress'] == 1) { $status = 3; } else { $status = 2; } if(isset($_POST['other_user'])) { $userID = $_POST['other_user']; } elseif(isset($_GET['other_user'])) { $userID = $_GET['us']; } else { $userID = $_SESSION['ID']; } // THIS IS WHERE WE SEND STUFF TO DB applicationSubmit($userID,$insertArray,$status); if($userID == $_SESSION['ID'] && $status == 2) { send_email($_SESSION['ID'],"has completed their application."); } if(isset($_POST['save_your_application'])) $sent = 2; else $sent = 1; } else { if(isset($_GET['other_user'])) { $userID = $_GET['other_user']; } else { $userID = $_SESSION['ID']; } $application = getUserApplication($userID); $detailsArray = array(); if(is_array($application)) { foreach($application as $key=>$val) { if(is_numeric($key)) {} else { if(strcmp($key, "id") == 0 || strcmp($key, "fk_userid") == 0 || strcmp($key, "status") == 0 || strcmp($key, "submit_date") == 0 ) { $detailsArray[$key] = $val; } else { $detailsArray[$key] = decrypt_app($val,$GLOBALS['SITE_CONFIGURATION']['KEY_APP']); } } } } //$detailsArray['status'] = getApplicationStatus($_SESSION['ID']); //print_r($detailsArray); }
  8. I'm trying to check if there is and image after the <td> tag, and if there is grab the width value. the method i'm using below is not working $element = $html->find("td", 23); if ($element->innertext != null) { $element = $html->find("td img[src=http://pictures.domain.com/images/7.gif]"); echo $element->width . '<br />'; } else { echo "empty"; }
  9. Hi i'm using Simple HTML Dom to scrap a site page. I'm trying to grab the width value for each img src. Below is the html and php i've been using so far. <table> <tr> <th colspan="4"> <font size="3" color="#a74165">Interest Levels</font> </th> </tr> <tr> <td nowrap> <font size="2">MobileT</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="1 on a scale of 0-4" border="0" height="15" width="9"> </td> <td> </td> <td nowrap> <font size="2">MobileC</font> </td> <td> <img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> </tr> <tr> <td nowrap> <font size="2">Moderate</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> <td> </td> <td nowrap> <font size="2">Males</font> </td> <td> </td> </tr> <tr> <td nowrap> <font size="2">Wild</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> <td> </td> <td nowrap> <font size="2">Females</font> </td> <td> <img src="http://pictures.domain.com/images/7.gif" alt="4 on a scale of 0-4" border="0" height="15" width="36"> </td> </tr> </table> include('simple_html_dom.php'); $html = new simple_html_dom(); $html = file_get_html('http://dev.domain.com/'); $element = $html->find("td font[size=3]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font", 7); echo $element-> plaintext . '<br>'; $element = $html->find("font[color=red]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font", 3); echo $element-> plaintext . '<br>'; # city state country $element = $html->find("font[size=2]", 3); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 10); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 11); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 12); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 1); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 2); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 3); echo $element-> plaintext . '<br>'; $html->clear();
  10. Hi does anyone have an example of using a PHP code to access the .htpasswd file for a user / pass login.
×
×
  • 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.