chawezul
Members-
Posts
19 -
Joined
-
Last visited
Never
Everything posted by chawezul
-
<?php //header ("Content-type: image/png"); $img_handle = ImageCreate (230, 20) or die ("Cannot Create image"); $back_color = ImageColorAllocate ($img_handle, 0, 10, 10); $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191); ImageString ($img_handle, 31, 5, 5, "My first Program with GD", $txt_color); //ImagePng ($img_handle); ?> Run this and see if there is any output in the page source. You may have a built-in function that runs before everything else in PHP.
-
If a variable number or records may be added into the database (ie, 3 or 4 or 2 or 1 are all acceptable), I would recommend imploding all of the records together into one string and keeping them in one database field, then exploding them back into seperate records when you take them out of the database. That's how my blogs handle tags, it works very well with variable amounts of input.
-
Make your script print() or echo() your query string out to you, then paste it into PhpMyAdmin or similar and see if it yields any errors or hints.
-
[SOLVED] Finding the longest word in a string
chawezul replied to Yesideez's topic in PHP Coding Help
<?php function longest($str) { $ar = explode(" ", $str); $ln = $ar[0]; for($i=0; $i < count($ar); $i++) { if (strlen($ar[$i]) > strlen($ln)) { $ln = $ar[$i]; } } return $ln; } ?> Arrays ARE quick and easy. -
Your query is sound and it worked on my system. Perhaps you didn't select a database with mysql_select_db() ? Also you can try to see if $cat gets deleted or set to "" at any point.
-
[SOLVED] echo problem passing values to a function. Please help.
chawezul replied to sayedsohail's topic in PHP Coding Help
Err in the new code you also don't have quotations around ${name} -
[SOLVED] echo problem passing values to a function. Please help.
chawezul replied to sayedsohail's topic in PHP Coding Help
Does that new page have the values in the query string? You could possibly go <script type="text/javascript"> var cname = <?php echo $_GET["cname"]; ?>; </script> -
$array[mt_rand(0,count($array))];
-
[SOLVED] echo problem passing values to a function. Please help.
chawezul replied to sayedsohail's topic in PHP Coding Help
Ah Check your Javascript console to make sure you're not sending: passvar(1, 3, name ,this); Because in that name is a constant! Try: <?php echo "<tr id=\"action\" title=\"Click to display sites below\" onclick=\"passvar(${pageNum}, ${id}, '${name}', this );\">"; ?> thanks! <ins>By the way, in that case the error you would get is: Variable 'name' is undefined in ... on line ...</ins> -
Easy comma-delimited list to dropdown box converter
chawezul replied to Chad Seibert's topic in PHP Coding Help
I don't know much about Regex, but I would go about using explode() with the ", " to break it into an array, then loop through it and echo <option id="${exploded[$i]}" /> -
[SOLVED] echo problem passing values to a function. Please help.
chawezul replied to sayedsohail's topic in PHP Coding Help
Can you supply more of the code? From what I've seen it should be working perfectly, there's gotta be something interfering with $name that I can't see. -
[SOLVED] Any work around for printing data of two different MIME types?
chawezul replied to Sandip's topic in PHP Coding Help
If you get have a PHP file that gets the image form the database then echo()'s it out, you can put header("Content-type: image/gif"); at the end to have it sent as an image (in this case gif), from there you can embed it in your HTML page with your basic img tag -
[SOLVED] echo problem passing values to a function. Please help.
chawezul replied to sayedsohail's topic in PHP Coding Help
You can use <del>single</del> <ins>double</ins> quotes <?php echo "<tr id=\"action\" title=\"Click to display sites below\" onclick=\"passvar(${pageNum}, ${id}, ${name}, this );\">"; ?> -
Notice: Undefined variable: idstud in c:\program files\eas.....
chawezul replied to pontiac007's topic in PHP Coding Help
You need to tell PHP which session values to take as well as to set, so You'd go session_start(); session_register("idstud"); session_register() will "tell" the computer that you are going to allow reading and writing of a session value of whatever you input. Otherwise it doesn't know that. After that you can set and access it from the public field $_SESSION["idstud"]; Hope that helps -
You can also use parse_str() on $_SERVER["QUERY_STRING"] for a register globals effect, getting the query string is generally easy if you're only passing one value to the script, but if you're using it with parse_str it's frowned upon and begs for injection.
-
Great thanks just what I wanted definatly helps a bunch!!!
-
When I create a new php file in dreamweaver and open it, I get [code]<!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> [/code] Wheras I'd like to get something like: [code]<?php // author: // date: class * { function __construct() { } } ?>[/code] Does anyone know how to do this?
-
It's kind of hard to understand what you're asking, plus you didn't show us how this query is applied to your code so it's harder to understand what you're trying to do with the result. But if you want to grab more columns (and assuming you don't have a million) you can simply use [code]SELECT * FROM `table` WHERE condition[/code] And that will grab all of the columns. Sorry if I didn't answer your question.
-
Ok, here's my problem, I want my function to return an array of numbers that are the prime factors of the input number. My code works. It's all good. Everything is great. Except, the array that is returned is only ONE item long, and it is the last item in the array. So my assumption is that everytime it calls to add to the array, it simply empties the array (or recreates it) and then adds the item. If you can help me that'd be great! Code: [code]$result = Array(); function prime($n, $y) { if ($y == 1) return true; elseif (($n % $y) == 0) return false; else return prime($n, $y-1); } function findprimes($n, $p) { if (! (prime($p, $p-1))) return findprimes($n, $p+1); elseif ($n == $p) { $result[] = $n; return $result; } elseif (($n % $p) == 0) { $result[] = $p; return findprimes($n/$p, $p); } else return findprimes($n, $p+1); } function primefactors($n) { return findprimes($n, 2); }[/code]