Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. So the first thing I can do to help you is to teach you to fish -- on php.net. If you use php.net, and append the name of a function, you'll go to the online manual for that function. As was suggested: http://www.php.net/strpos -- should let you look for the location of the first comma. Your assumption is that before that is the user's name. Once you know that the substr function can get you the parts of the string. http://www.php.net/substr These will give you a lot of control. With that said, explode is pretty great function, and you can actually get around laffin's issue using the optional param that limits the number of pieces to 2. // $input should be sanitized version of the message from the $_POST. $msg = explode(',', $input); $user = trim($msg[0]); $text = trim($msg[1]);
  2. print_r or echo out the $sql and see what it looks like. I don't see wehre you define $userid or $time, and of the two I suspect that $time might not be defined, or might be in a format that is incompatible. Also, you're just better off not messing around with moving date and time between php and mysql and just staying with mysql built in date handling functions. I've written about this topic quite a bit on my blog: http://www.gizmola.com/blog/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html http://www.gizmola.com/blog/archives/99-Finding-Next-Monday-using-MySQL-Dates.html http://www.gizmola.com/blog/archives/93-Too-much-information-about-the-MySQL-TIMESTAMP.html
  3. $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="forum_question"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get value of id that sent from address bar $id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> </pre> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> echo $rows['topic']; ?> echo $rows['detail']; ?> By : echo $rows['name']; ?> Email : echo $rows['email'];?> Date/time : echo $rows['datetime']; ?> </table> <br><br><br>$tbl_name2="forum_answer"; // Switch to table "forum_answer"<br><br>$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";<br>$result2=mysql_query($sql2);<br><br>while($rows=mysql_fetch_array($result2)){<br>?><br><table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> ID : echo $rows['a_id']; ?> Name : echo $rows['a_name']; ?> Email : echo $rows['a_email']; ?> Answer : echo $rows['a_answer']; ?> Date/Time : echo $rows['a_datetime']; ?> </table> <br><br><br>}<br><br>$sql3="SELECT view FROM $tbl_name WHERE id='$id'";<br>$result3=mysql_query($sql3);<br><br>$rows=mysql_fetch_array($result3);<br>$view=$rows['view'];<br><br>// if have no counter value set counter = 1<br>if(empty($view)){<br>$view=1;<br>$sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'";<br>$result4=mysql_query($sql4);<br>}<br><br>// count more value<br>$addview=$view+1;<br>$sql5="update $tbl_name set view='$addview' WHERE id='$id'";<br>$result5=mysql_query($sql5);<br><br>mysql_close();<br>?><br><br><br><table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> Name : Email : Answer : </table Ok, so I see the code was there, but with the short tags, I missed it. Maybe you don't have short tags on, and it's not parsing it. Make sure that all the start tags are <?php and not . I fixed in the code block above. Try it and see.
  4. I guess you can try the basedir + /bin/mysqldump. Very strange that whereis can't find the binary, but you could be testing in a chrooted/fastcgi environment.
  5. Yes no kidding, your script has a while loop up top, then drops into a mass block of html, and never drops back into a php block to close out the while loop. Therefore, PHP is helpfully telling you that you had an "Unexpected end". Seems you are missing part of the tutorial code, or you didn't cut and paste well.
  6. It's actually a really bad solution, and one that you will find very problematic depending on the content in your pages. How about confronting the source of your problems -- why is magic_quotes_gpc turned on, when it has been off by default for many years now? Are you able to turn it off on your server? If so, why don't you do that rather than looking for bandaids that can easily turn your data into garbage?
  7. So, based on that info, you'd be better off just searching for mysqldump directly using whereis -b mysqldump. If you don't find it, your backup script is probably not going to work.
  8. Hey one last thing about the prior discussion of whereis... if you run it with the -b switch it will only look for binaries. You can also capture the output directly into a string using the backtick operator. $out = `whereis -b mysql`; echo $out. You still have to parse off the front mysql: and explode out the findings, in case it returns multiples.
  9. This outputted: /usr/local/ At least I'm a step closer I just need "bin" on the end Would mysql always be installed */bin/mysql is that why its output is /usr/local/ or am I not getting the correct output??? Thanks again Yes mysql's startup is kinda hinkey stuff -- it's just scripts, but they do append a /bin onto the end of basedir. It's kind of silly that there isn't a system variable in mysql that shows you the path to the binary, but ... oh well. Of course it's not really clear why you need to know this. For example, there could easily be a php install that has no mysql binaries available, and only the client librariy, because the webserver is connecting to a mysql server on a different host. *edit* ok I saw you posted about this while I was writing this. Not sure how your backup script approaches things -- if it just calls mysqldump, then there's nothing you can do if the mysqldump isn't there, nor is there much you can do if the process running apache doesn't have permission to get to it or run it.
  10. Sounds like you have magic quotes GPC turned on. Here's the page about it. It sucks, it's deprecated, and scheduled to be removed. Turn it off on your server. Instructions and more information are included here: http://php.net/manual/en/security.magicquotes.php
  11. First off, change your query to: SELECT * FROM downloads WHERE id=5 ORDER BY links This will sort them in ascending order. Then it looks like you want to parse out the domain from the $row['links']; Something liike this ought to put you on the right track: $domain = ''; while ($row=mysql_fetch_array($q)) { $t = parse_url($row['links']); if ($domain !== $t['host']) { $domain = $t['host']; echo "$domain\n"; } echo '' . $row['links'] . "\n"; }
  12. You really need to clarify your question. Is this a database issue or a problem with your understanding of string manipulation, or a problem with your understanding of PHP, or ???? Let's see what code you have, and a describe on any pertinent database tables.
  13. I've implemented recaptcha with a variety of frameworks and forums. Depending on the forum or opensource application it might take some detailed theme or code mods to make it work, but there's no fundamental reason it can't be used by you, despite any prior issue you have encountered.
  14. Everyone takes their own path. I think you've made some good decisions so far, although you're right that necessity is the mother of invention. I have been at this a long time, and I learned some fundamentals along the way, including 808x assembler (which was pretty helpful in showing how computers work at their fundamental level) and c and c++. Web development is a complicated endeavor and often underestimated because it involves so many moving parts, and interrelated technologies. In terms of your current application, while it sounds fundamentally sound, it also sounds like you could take it farther, by enhancing the UI with some DHTML and ajax, which will be an excellent proving ground for your current skills. Most starting developers come into a situation where they spend some time apprenticing for some senior develpers, and you haven't had that experience yet. An experienced develper might find some issues with your code and approaches, but in a vacuum, you're unlikely to go much further with that approach. You could learn a lot from looking at framework code like that from Zend Framework or Symfony. With that said, it would be very helpful if you were to pinpoint exactly what it is that you want to be doing in the near time frame. Basically, what I got from your original post is that you have a pc tech job, and want to be a coder. It seems that's your first issue -- you're not working in a place where you are paid to program. So you either need to: -Look for a job where you can be paid to program -Program at night and weekends when you come home -Contribute to an open source program (also at night and weekends)
  15. Just to beat a dead horse, this is in the TOS in the forum guidelines section:
  16. Please don't make posts that describe your problem as urgent. Nobody cares about the urgency of your problems. In fact, we so don't care that we've explicitly discussed this in the forum rules. With that said, what you want to read about is the css box model, and in particular you want to understand, margin, border, padding and content, and how they all relate. Read these: http://www.w3.org/TR/CSS21/box.html http://www.brainjar.com/css/positioning/default.asp Once you have a solid understanding of the box model basics and the two types of box types (Block vs. Inline) you are ready to tackle your alignment questions. I'm not sure from your original post if you already figured that out or not, but: http://www.w3schools.com/CSS/pr_text_text-align.asp Please read the rules, aka Terms of Service, aka TOS -- link below in my signature.
  17. Since bbcode depends on the use of square brackets to delimit a code, I think the "left" one that includes said brackets is a little clearer.
  18. I wonder what "Loosers" are? People that leave the doors open so that their pets get out, or careless zookeepers, or perhaps just people who have to keep redoing their shoelaces? Shame that zeroge won't be back to fill us in on this fascinating concept. I know I will hardly be able to get to sleep because my mind will be working overtime as I attempt to untangle this riddle inside an enigma inside a mystery. "LOOSERS INDEED!" and why are they plagued by THE DUSTY BREEZE! ArghhhhhhhhhhH!!!!!!!
  19. You are missing something somewhere. My simple code does indeed work. Full script here: $text = '#username#username2# wasup guys!'; $string = explode ('#', trim($text, '#')); print_r($string); Output using php -f [david@penny ~]$ php -f explode.php Array ( [0] => username [1] => username2 [2] => wasup guys! )
  20. If you want to implement a string constant, then just use the single quotes. echo ' click image for bigger view';
  21. Why make this so complicated. Just trim off the start and end "#". print_r(explode('#', trim($str, '#'));
  22. I don't understand your database enough to comment on this effectively. However, what you're basically asking for seems to be a non-post change. The generic term for this type of thing is AJAX. These days, the most heavily used javascript library for implementing ajax calls is jquery. Do some reading on the jquery site on this. In essence you will tie an event to whatever widget, and have that issue the ajax call back to your website, which will update the appropriate column. You should be able to write a simple script that takes the required parameters and does the update -- then it's simply a matter of calling it through jquery. Start a seperate thread in the Ajax Help section if you get stuck, but please don't do that until you've written the update script and unit test it, AND read the jquery docs, AND coded a simple proof of concept which uses jquery. I took this simple example right out of the jquery manual: $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } });
  23. Take a look at your urls. The format of a url is: scheme://domain?param=value&parm2=value& etc. Your url example is showing domain?param=value&?... You can't have that question mark in there, it's a problem that is disrupting the parsing done by the webserver and subsequently the $_GET. Also, when you have things like spaces in a url param, it needs to be handled aka, url encoded. You should url encode your parameters. PHP gives you a nice function to help you with this: http://us2.php.net/urlencode There are probably other logic issues with your code, but at least these will help you figure out some of the mystery.
  24. Which API are you using? Are you using the UK payflow pro 4 api? We have a number of Brits on the forum who might be able to help you if that's the case. I'm not sure if that's required in the UK, but since you mentioned pounds, I thought it might be pertinent.
×
×
  • 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.