AyKay47
Members-
Posts
3,281 -
Joined
-
Last visited
-
Days Won
1
Everything posted by AyKay47
-
perhaps your query is not returning any rows in its results set. Add a little more error handling. $sql="select shortdescription from links where category = '".$scat->id."'"; $result=mysql_query($sql) or die(mysql_error()); $row=mysql_fetch_row($result); if(!$row) { echo "no rows grabbed"; } else { $shortdesc = array_shift($row); }
-
why would you assume that $_SESSION['order']['content'] is empty? was "lol" the only key/value in the array? have you tried print_r()ing or var_dump()ing the array to make sure that it is truly empty? The problem is not with unset(), the problem is that your condition is not returning true.
-
these two warnings tell you exactly what the problem is.
-
I have not yet taken a look at it, and from your report, I probably won't. I am surprised (kind of) that mozilla hasn't gotten their crap together after the launch of chrome. I actually just installed it as I was writing this post, and I must say I am surprised, this is almost an exact replica of chromes dev tools (GUI is nicer) with the exception of as you said, lacks a good bit of functionality. The GUI is nice, but I personally (mostly everyone I assume) would never sacrifice functionality for a nice interface. Firefox is still a browser that cannot compare to chrome. I agree completely, firefox will always be catching up to chrome because they lack imagination, it seems to me that they wait for chrome to come out with some new features, then simply copy them in the next release (however yet again failing to keep up with chrome). IE will of course be the ladder of browsers most likely forever. After reviewing this, firefox remains to be a browser that I have no desire to use.
-
addressing solely the issue at hand, which is this foreach loop: foreach($_POST['product'] as $value) { $product_msg .= " - $value"; } a foreach loop is used to iterate through an array, which I assume you already know. The value of $_POST['product'] is a type string, which cannot be used in a foreach loop. Also, you do not assign $product_msg a value before attempting to concatenate a value onto it, this will also result in an error. Using $_SERVER['PHP_SELF'] as a forms action leaves the form wide open to XSS attacks. Instead leave the form action blank, this will give the same results as using php_self.
-
Thorpe brings up a good point, maintainability of the site. It is a good practice to have meaningful names when choosing variables, PHP OOP class names, function names, CSS class names, etc.. This will help both you when you come back to your code a month later, and another programmer picking up your work. Bottom line here is, changing your class names will be much more of a hindrance then help. You will not notice a performance difference in any case.
-
Dual language support: right to left, and left to right
AyKay47 replied to YigalB's topic in PHP Coding Help
Without seeing the logic in your code, it would be impossible to tell you exactly how you should implement this into your code. The method you provided could work, although it seems tedious to write many if statements. Again, without seeing how you are setting up the different language texts, it's hard to say. However something along the lines of determining what language the text is, and wrapping it in an element with the direction class dynamically is most likely what I would do. You can also detect the strings encoding using an mb function, mb_detect_encoding and act accordingly. -
These differences would be a miniscule amount of memory. In terms of optimizing a website, think query optimization, utilize functions instead of re-writing unnecessary code, utilize proper caching techniques. Things along these lines will make a much bigger difference where speed is concerned.
-
When comparing two values, use the comparison operator == not the assignment operator =. Your code should looks like this. $id = (int)$_GET['id']; if ($id == 1) { echo "This is challenge 1 completed"; } elseif ($id == 2) { echo "This is challenge 2 completed"; else { echo "The URL parameters didn't work"; }
-
script displays at the bottom of the page... why?
AyKay47 replied to SF23103's topic in Javascript Help
The input field is being displayed at the bottom of the page because you are telling it to. This line. $('body').append('<p>LAT: <input name="LAT_LON" type="text" value="' + lat + ' ' + long + '" /></p>'); Tells JavaScript to append (place after all child elements inside the selector element) the input, in this case the selector is the entire body. What you can do is inject the input into a desired element by using $("selector").html(input); -
good catch, my code is updated, OP you will need to pass this variable when calling the function, as noted.
-
function name($id) { $lookup = "SELECT firstname, lastname FROM myMembers WHERE id='$id' LIMIT 1"; $result = mysql_query($lookup); if(!$result) { echo "Query: {$lookup}<br />Error: " . mysql_error(); } elseif(!mysql_num_rows($results)) { echo "There were no results."; } else { $row = mysql_fetch_assoc($result); $name = "{$row['firstname']} {$row['lastname']}"; echo $name; //function needs to output this } }
-
this will be my last post, as you do not understand what I am telling you. You are receiving 1234567 as output because each iteration it is outputting a singular number. e.g The first iteration $counter outputs 1, the second iteration $counter outputs 2, etc.. the value of $counter does not equal 1234567 as it appears, all 7 values are simply next to each other. If you want to see for yourself, instead of just echoing $counter, echo $counter . "<br />"; and then see what your results are. The code that you need to find the last iteration is on this thread no less than 3 times. There is no more need to write more code that you will not understand.
-
yes this was a tiny mistake on my part, the error is due to not concatenating the string correctly, if you want to use $_POST directly in your query, change it to this. $match = "select user_id from $table where username = '". $_POST['username'] ."' and password = '". $_POST['password'] ."'";
-
just reviewed your code, im confused as to why you stated that the similar code that scootstah and I provided would not work for you, as the solution is basically the same. This is a modified snippet of your code. if ( $DB->get_num_rows() ) { $last_forum_id = -1; while( $topic = $DB->fetch_row() ) { $counter++; //$counter should begin with a value of 1, $counter++ should be placed at the bottom of the loop if($counter == $DB->get_num_rows()) //indicates the last iteration { //code to execute on the last iteration }
-
i see what you are trying to do, the code that we have already provided is what you need, attempt to implement it into your code. But, to answer your question on why substr() isn't working. 1. $cats will not contain 1234567 when echoed after the loop is finished 2. substr() expects parameter 1 to be type string, $cats is type int 3. if you want the last iteration value outside of the while loop, $counter will hold that value outside of the loop, if you want to echo something on the last iteration, refer to the code already given.
-
alright, since your loop is grabbing database data as I expected, I will post dummy code that you can use to get the idea and implement into your code. $index = 1; while($row = $DB->fetch_row()) { //code if($index == $DB->num_rows()) //this indicates the last iteration { $last_iteration = $index; //stores the last iteration value } $index++; } Edit: or scootstah could vulture this thread.
-
Yes, when i Do it, it echo's 1234567 but how can I get just "7" out of the loop? i need to use it in a variable i dont need to use the 1234567 just need the last number, or the sum of all which is 7 last time i checked, 1+2+3+4+5+6+7 != 7, but maybe something changed. okay so you want to only echo the last iteration, or store it in a variable. Can you post the loop so I can have a look?
-
im not sure that im following you. you want $counter to contain the sum of the iterations?
-
Warning: readfile() [function.readfile]: Help Please
AyKay47 replied to Wedgewood85's topic in PHP Coding Help
as stated, this error revolves around $_GET['img'] not being set. You should be checking if it is set using isset before proceeding with your code. -
has your issue been resolved?
-
Warning: readfile() [function.readfile]: Help Please
AyKay47 replied to Wedgewood85's topic in PHP Coding Help
without seeing the relevant code, debugging this will be impossible for us. If you cannot figure this out on your own (I encourage you try) then post the relevant code and we will help. -
Warning: readfile() [function.readfile]: Help Please
AyKay47 replied to Wedgewood85's topic in PHP Coding Help
the given error is telling you everything that you need to know in order to debug this. figure out why $img would be empty, something in your code has obviously changed. what exactly does this mean? -
Dual language support: right to left, and left to right
AyKay47 replied to YigalB's topic in PHP Coding Help
I would prefer to use CSS for this, as it makes the code a little more robust and easy to maintain. CSS has a property for this called the "direction" property which has three possible values: ltr (left to right, default), rtl (right to left) and inherit meaning it inherits the direction property from its parent element. As ManiacDan stated, a class for this can be made and be assigned to any text that you want this to affect. There are several ways to implement the ltr, rtl change as well.