AviNahum
Members-
Posts
170 -
Joined
-
Last visited
Everything posted by AviNahum
-
sort images from the highest to the shortest
AviNahum replied to AviNahum's topic in PHP Coding Help
works great! Thank you! -
i'm trying to create a function thats sorts 4 images from the highest one to the shortest one... // array of my images $images = array($proj['image1'], $proj['image2'], $proj['image3'], $proj['image4']); $sorted = array(0, 0, 0, 0); // put all heights in array for ($i=0; $i<4; $i++) { list($width, $height, $type, $attr) = getimagesize("admin/images/projects/".$images[$i]); $sorted[$i] = $height; } // sort it from the bigest number to the lowest rsort($sorted); // this gonna contain the sorted images $si = array(); for ($i=0; $i<4; $i++) { list($width, $height, $type, $attr) = getimagesize("admin/images/projects/".$images[$i]); for ($j=0; $j<4; $j++) { if ($sorted[$j] == $height) $si[$j] = $images[$i]; } } but if there two images with the same height, it's repeat this images few times... any ideas? Thanks!
-
<?php error_reporting(E_ALL); $con = mysql_connect('localhost', 'root', ''); if (!$con) { die('Connection Error:' . mysql_error()); } mysql_select_db('catgories', $con); for($i=0;$i<=17659;$i++) { $query="INSERT INTO categories(products_id, categories_id) select $i,categories_id from categories"; mysql_query($query) or trigger_error("SQL: $query, ERROR: ", E_USER_ERROR); } ?>
-
simply, $_GET['JobID']; echo $_GET['JobID'];
-
I'm trying to build code that avoid spam comments on my site. I made a function that checks the last time the user commented, and if passed more than 30 seconds it allows them to comment again. i dont know why, but it's not work for me. this is the function: <?php public function check_spam() { global $core, $DB; //---------------------------------- // Select from DB the last reply //---------------------------------- $q4 = $DB->query("SELECT * FROM blog_articles_replies WHERE poster_ip='{$core->input['IP_ADDRESS']}' ORDER BY id DESC LIMIT 1"); $row = $DB->fetch_array($q4); //---------------------------------- // Format the time to seconds //---------------------------------- $last_post_date = $core->get_date($row['date'], "s"); $now_date = $core->get_date(time(), "s"); //---------------------------------- // Check if 30 seconds past //---------------------------------- if ( ($last_post_date+30) > $now_date ) { return TRUE; } else { return FALSE; } } ?> $core->input['IP_ADDREDD'] is the user IP ADDRESS; $core->get_date function: <?php public function get_date($date, $method="") { global $core; //---------------------------------- // Set an method if we didnt yet //---------------------------------- if ($method == "") { $method = "j/m/Y - G:i"; } //---------------------------------- // Returning //---------------------------------- return gmdate($method, $date); } ?> when i select 'DATE' from the DB, it's the miliseconds using time() function I tried to explain myself and my problem the best I can Thanks!
-
ok, the problem on my server... thanks any way...
-
i trying to get the user IP address with this code: $return['IP_ADDRESS'] = $_SERVER['REMOTE_ADDR']; echo $return['IP_ADDRESS']; but all i get is: ::1 i can't see any problems here. Thanks!
-
what error you get? are you calling to these functions?
-
need help for include function in my code
AviNahum replied to ineedhelp512's topic in PHP Coding Help
give us a link to your page, or tell me in what line was the error? -
need help for include function in my code
AviNahum replied to ineedhelp512's topic in PHP Coding Help
ummm i cant find any problems.... umm try to run this code and tell me if you get error: //displaying results echo " <div id='header'> <!--<h1>YellowPages</h1>--> <table border='0' width='100%'> <tr><td align='left'> <span><img src='images/banner_logo.png' alt='' /></span> </td><td> </td></tr></table> </div>"; include("navigation.php"); echo "<div id='content'> <div id='hspace'> <!-- horizontal space --> </div> <!-- horizontal space --> <table border='0' width='100%'> <tr> <td width='200px' valign='center' align='center'> <img src='images/contact.png' width='225px' alt='' />"; echo "</td> <td> <h2 class='title'>Number of businesses found: ".$totalResults." - Page ".$pageNum." of ".$totalPages."</h2> <div class='content'>"; /*if( $query == NULL ){ echo "SEARCH ERROR MESSAGE"; }else if ( strlen($city) == 0 && strlen($category) == 0 ){ echo "SEARCH ERROR MESSAGE CATEGORY"; }*/ //echo $query; i just removed the include ads.html if you dont get any error with this code, so the problem in your ads.html file... -
need help for include function in my code
AviNahum replied to ineedhelp512's topic in PHP Coding Help
you still get the same error? -
need help for include function in my code
AviNahum replied to ineedhelp512's topic in PHP Coding Help
ok, this should work... //displaying results echo " <div id='header'> <!--<h1>YellowPages</h1>--> <table border='0' width='100%'> <tr><td align='left'> <span><img src='images/banner_logo.png' alt='' /></span> </td><td> </td></tr></table> </div>"; include("navigation.php"); echo "<div id='content'> <div id='hspace'> <!-- horizontal space --> </div> <!-- horizontal space --> <table border='0' width='100%'> <tr> <td width='200px' valign='center' align='center'> <img src='images/contact.png' width='225px' alt='' />"; include("ads.html"); echo "</td> <td> <h2 class='title'>Number of businesses found: ".$totalResults." - Page ".$pageNum." of ".$totalPages."</h2> <div class='content'>"; /*if( $query == NULL ){ echo "SEARCH ERROR MESSAGE"; }else if ( strlen($city) == 0 && strlen($category) == 0 ){ echo "SEARCH ERROR MESSAGE CATEGORY"; }*/ //echo $query; -
multi-dimensional array - what am I doing wrong?
AviNahum replied to caughtinweb's topic in PHP Coding Help
<?php $shopping_list = $_SESSION['wantlist']; ?> <?php echo "<pre>"; print_r($shopping_list); echo "</pre>"; ?> <table width="300" border="1" cellpadding="20"> <caption> My Bead Want List </caption> <?php foreach ($shopping_list as $key_1 => $val) { foreach ($val as $key_2 => $val_2) { echo('<tr> <td class="name">'.$shopping_list[$key_1][$key_2].'</td> <td class="thumbnail"><img width="87" height="87" src="'.$shopping_list[$key_1][$key_2].'" /></td> </tr>') ; } } ?> i'm not sure it will work... -
echo " <img src='stackm.jpg' id='Image2' alt='test!' onmouseover='ChgText({$number}); MM_swapImage('Image2','','stackmrollover1.jpg',1);' onmouseout='MM_swapImgRestore()'/> "; if this one not work, try this: echo " <img src='stackm.jpg' id='Image2' alt='test!' onmouseover='ChgText(".$number."); MM_swapImage('Image2','','stackmrollover1.jpg',1);' onmouseout='MM_swapImgRestore()'/> ";
-
array( "file1.php" => "value", "file2.php" => "value", "file3.php" => "value", "file4.php" => "value", "file5.php" => "value", ); is this the way your array built?
-
Bah, Problems with my multi dimensional array.
AviNahum replied to yanjchan's topic in PHP Coding Help
sorry, i dont really know how to work with XML... -
need help for include function in my code
AviNahum replied to ineedhelp512's topic in PHP Coding Help
the [/b/] is not the part of his code, i think he added it in attempt to make the "include" bold so we can reconize it... but it's wont work in "code" tags... -
need help for include function in my code
AviNahum replied to ineedhelp512's topic in PHP Coding Help
you get any error when you running this code? or you just dont see anything? -
<?php class person { public $name; public $age; public function __construct($n, $g) { $this->name = $n; $this->age = $g; } } $a = new person("my name" , "my age"); ?> it would nicer to work this way, right?
-
Bah, Problems with my multi dimensional array.
AviNahum replied to yanjchan's topic in PHP Coding Help
<!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=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $answers = array( array( //2+2 is what!!! 'isdisputed' => 'yes', 'answers' => array( '1' => array( 'propnum' => '4', 'grades' => '84,98,42,67', 'answer' => '5' ), '2' => array( 'propnum' => '10', 'grades' => '100,98,99,86,86,20,86,100,100,100', 'answer' => '4' ) ) ) ); $xw = new xmlWriter(); $xw->openMemory(); //use openUri() to output directly to a file $xw->startDocument('1.0', 'UTF-8'); $xw->startElement('share'); $xw->writeElement('page', 'page#'); $xw->writeElement('numsequence', 'numseq'); $xw->writeElement('publisher', 'pub'); $xw->writeElement('book', 'bookname'); foreach ($answers as $answer) { $xw->startElement('answer'); // $xw->writeElement('answernumber', $answer); $xw->writeElement('isdisputed', $answer['isdisputed']); foreach ($answers['answers'] as $disputedanswer) { $xw->startElement('disputedanswer'); $xw->writeElement('supporters', $disputedanswer['propnum']); $xw->writeElement('grades', $disputedanswer['grades']); $xw->writeElement('answer', $disputedanswer['answer']); $xw->endElement(); } } $xw->endElement(); //item echo $xw; ?> </body> </html> -
$query2 = "SELECT * FROM user WHERE username='{$_SESSION['username']}'"; change the username to the name of the colume in your DB
-
Bah, Problems with my multi dimensional array.
AviNahum replied to yanjchan's topic in PHP Coding Help
what error you got? -
if you got more questions, ask away...
-
yes, you can use this method, easy and simple...
-
i think the global variables are disabled in your server, you have to talk to your admin server and ask him to enable global vars option...