Jump to content

Twist3d

Members
  • Posts

    62
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Twist3d's Achievements

Member

Member (2/5)

0

Reputation

  1. Ok, I've fixed the errors. Now, all it is doing is this: This is the code: <?php $db = mysql_pconnect("localhost","root",""); mysql_select_db("test",$db); $time = time(); $result = mysql_query("SELECT * FROM timer"); while($row = mysql_fetch_array($result)) { $timestamp = $row['timestamp']; $check = $row['check']; if ($check=="0") { mysql_query("UPDATE timer SET check = '1' WHERE id = '1'"); mysql_query("UPDATE timer SET timestamp = '$time' WHERE id = '1'"); } elseif ($check=="1") { $timenow = time(); $timecheck = $timenow - $timestamp; echo $timenow; echo $timecheck; if ($timecheck >= "10") { echo "bigger then 10, do what ever at the end of the countdown here"; mysql_query("UPDATE timer SET check = '0' WHERE id = '1'"); mysql_query("UPDATE timer SET timestamp = '' WHERE id = '1'"); } } } ?> Why is it just echoing the current time twice, and doing what it should do if it those two where minused and if the answer was bigger then 10?
  2. Hello. Well I am really annoyed at myself at the moment. I am trying to make a timer script that is uninterrupted by a refresh of the page, so this to me would be a Mysql database thing to check My idea was simple, at least until I forgot it. But, I was going to grab the current time using time(); and place it into the database. Then I would set another value in the structure called check, to 1. The database while the value is set on 1 will keep checking every time a user refreshes. It would get the time from the database that was set, and the current time again. It would take away the stored time from the current time and if that value equals less then ten, it would keep running the script and won't change the check. But if it was over ten, it would do a random function (What ever the user wanted, right now it just an echo for a test) and delete both the current timestamp in the database, and set the check to 0. If the value was 0, it would set the new timestamp in the database, eg the current time, and set the value to 1 so it will keep running again. Is this possible? It is getting a bit annoying, getting a few errors, again like most of the time its little ones that I can't seem to put my finger on. Hey, we have all started somewhere :/ This is my code so fare: <?php $db = mysql_pconnect("localhost","root",""); mysql_select_db("test",$db); $time = time(); $result = mysql_query("SELECT * FROM timer"); while($row = mysql_fetch_array($result)) { $timestamp = $row['timestamp']; $check = $row['check']; } if ($check=="0") { $query = "UPDATE timer SET check = '1' WHERE id = '1'"; $query .= "UPDATE timer SET timestamp = '$time' WHERE id = '1'"; multi_query($query); } elseif ($check=="1") { $timenow = time(); $timecheck = $timenow - $timestamp; if ($timecheck >= "10") { echo "bigger then 10, do what ever at the end of the countdown here"; $query2 = "UPDATE timer SET check = '0' WHERE id = '1'"; $query2 .= "UPDATE timer SET timestamp = '' WHERE id = '1'"; multi_query($query2); } } ?> Now even looking at this code confuses me, and I wrote it. I tested it, I expected an error and got one. As you have probably already stated, I am a very small form of BASIC at PHP, would anyone like to push me in the right direction as to how to get this working?
  3. They won't actually be placed ONTO the image tho would that, just placed ontop @litebearer. That is text onto text, will imagettftext or some other GD function work with CSS?
  4. Hello. Well I haven't any code for this, but its only a question. Do you think it would be possible for PHP, to make and image or draw one from just a blank JPG. Then placing text on the image. That is possible and quite simple. But do you think it is possible to say. Say if you have 3 different set of texts on the image. Click here for 1 Click here for 2 Click here for 3 And also for the script to link those text to different web addresses. But all still workable with a dynamic signature EG [ img ] [ / img ] Basically its a dynamic signature with links on it is what i am trying to say. Do you think its possible? Or am I thinking to big.
  5. Twist3d

    Eval

    O, I just found out one of my mates just tried testing it. I found out what the problem was and fixed it. Thanks again for your help and patients, all works good now. Nice solution to, I knew the dangers of the Eval but it felt like my only solution, I didn't think looping the line would work, but I don't know why I thought that haha.. Thanks again.
  6. Twist3d

    Eval

    I tried your code, I got these errors: And ALOT of random images and symbols appear as well. I tried shortening the amount of rows in the database, that helped a little but the problem above still occurs.
  7. Twist3d

    Eval

    Ok, I have done that and ended up with this: <?php //connect $db = mysql_pconnect($dbhost,$dbuser,$dbpass); mysql_select_db("$dbname",$db); $query="SELECT * FROM info"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $x = $row['x']; $y = $row['y']; $text = $row['text']; } header("Content-Type: image/jpeg"); $im = ImageCreateFromPng("test.png"); $black = ImageColorAllocate($im, 255, 255, 255); Imagettftext($im, 12, 0, $x, $y, $black, 'verdana.ttf', "$text"); Imagejpeg($im, '', 100); ImageDestroy($im); ?> As you told me before to take the header stuff out of the loop. Is this what you mean? Because I just tried, it again displays the image but doesn't write the text. Woops, just made a bit of a mistake when I quoted my entire code Sorry.
  8. Twist3d

    Eval

    As I explained, yes I am. Where else could I store it? In a TXT file? It is so I can add more stuff to the image if it needed more text on it, and so other people can do it and not just me and not manually.. And i'm aware of how bad eval is, but if you could provide an alternative way of doing this, please do. @PFMaBiSmAd As I just explained, If a user wanted to add another point to the image, he can. I'm making like a map-type of thing, you click a spot on the map, it reads it, puts all of the info in the database, and the image which contains the map reads ALL the points, and puts all the text onto the image. If I was just to hold the X and Y coords (which I already am) how could I add more points (Which means add more of the Imagettftext()) without doing it manually? This is my problem, and I'm open to new suggestions. I really didn't want to use Eval but at the moment I think its my only option.
  9. Twist3d

    Eval

    Well from the fantastic response on my last post (0 replies, 80+ views), I've decided to browse A LOT of articles on how to do what I need to do. And, well I got it down to the function in PHP as Eval. I have my code set up like this: $query="SELECT * FROM info"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $x = $row['pointtext']; echo $x; } As you can see this, this is a simple query to grab all the rows under pointtxt. I have only 1 at the moment which is to text it, and it echo's it fine! It echo's this: Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "text to write"); This is a PHP script for TEXT-TO-IMAGE. SO then considering the echo worked, I used this code: $query="SELECT * FROM info"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $x = $row['pointtext']; header("Content-Type: image/jpeg"); $im = ImageCreateFromPng("test.png"); $black = ImageColorAllocate($im, 255, 255, 255); $start_x = 10; $start_y = 20; eval($x); Imagejpeg($im, '', 100); ImageDestroy($im); } And as you can imagine, it doesn't work. As I said in my 2 day old topic, I want it to have the ability to put more text onto the image and save it. So, do I get help this time? PLEASE. Does the eval function not support the TEXT TO IMAGE got an error in the script. What, please at least answer this time. _______ Also forgot to mention that how the script doesn't work, is it displays the picture fine, but it doesn't place any text onto it. Or any I can see with the set coords.
  10. Hello guys. Well I've ran into a sorta crossroad here with this script. See I'm trying to create like a click to make point system on an image. I have it all working except 1 problem.. At the moment the text to image script is only adding 1 bit of text onto the image, that is fine, that is because this is the only one in the php file: Imagettftext($im, 12, 0, $X, $Y, $black, 'verdana.ttf', "$text"); But, what I am trying to do is to let the user create more points. I thought I could achieve this by a database and just echoing out all of the rows from point txt which are like the above. So it will be like Imagettftext($im, 12, 0, 342, 455 $black, 'verdana.ttf', "$text"); Imagettftext($im, 12, 0, 443, 953, $black, 'verdana.ttf', "$text"); Imagettftext($im, 12, 0, 553, 445, $black, 'verdana.ttf', "$text"); And every time a user adds another point another one of the above is added to the database, it is then read by the TXT file, and displayed onto the image. Although I only have this running at the moment: <?php echo $row['pointtxt']; ?><br> And for a test I just tried a simple echo command, and this is the only record or row in the database in the field pointtxt: echo "hello"; As you can image, I don't think an echo can echo PHP commands, sorry this is really hard to explain, if anyone needs further explaining tho I will try. Its basically I just want a user to add one of these into the database Imagettftext($im, 12, 0, 553, 445, $black, 'verdana.ttf', "$text"); And on the image, it will grab all of those from the database, and run them so they all appear on the image. Thanks for your help.
  11. Sorry for the gravedig but Id really appreciate it if someone could help as I do need this.
×
×
  • 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.