PHP and MySQL confusion (1 Viewer)

Super Dexta

New Member
Joined
Aug 15, 2002
Messages
7,841
hi lads,
my code here may well be kinda ridiculous, all my PHPing is basically flailing in the dark until something works.

basically i have a URL to an image stored in my database, and I want to be able to pull out different URLs with PHP and display the actual images. at the moment i'm just getting a red X. I can get the URL out no bother, it's making it into an actual picture that's the problem.

at the moment i'm doing

PHP:
$result = @mysql_query("SELECT pic FROM gradinfo where email ='$email' and pass ='$pass' ");
if (!$result) {
exit('Error performing query: ' . mysql_error());
}

while ($row = mysql_fetch_array($result)) {
echo "<img src=<'".$row['pic']."'>";

}
 
Have it working now. Superfluous angle bracket caught me again. Annoying when it's something simple like that.. there's been two of us trying to get that working since yesterday :eek:
 
if you're totally lost on a debug, comment out half of the code, see if its ok, and keep on reducing by half the commented stuff until you are at the line in question.


That will happen pretty fast, and once you are there, cut and paste that line somewhere out of sight, and then rewrite the line or block in question.

9 times out of 10 you will just write it properly the second time around, instead of trying to see the error.
 
I knew what line was the problem this time. I just didn't know what to do with it :eek: I actually had rewritten it a heap of times, just obviously left my brain at home today.

Now we have a chunk of JavaScript that was working three hours ago, nobody touched it or the page that it's in since then, and now it's not working. Dose.
 
I know... in the above you did.
This was just a for your information post.

Usually you should take a break after you find out the line in question, and moved it out of sight.

But, as a general rule, I find this method works.


for js, use the browser's debugger thing, CTRL shift J in firefox.
 
handy out. turns out 'no-one has touched it' means 'someone renamed a variable and forgot about it'. must spread, etc.


that's another tricky enough thing I have learned over the years.
When you think you made no mistakes, and the computer thinks its made no mistakes, the computer is normally right.
 
whats the function for selecting a little bit of a lump of text and giving it a $name of its own? like if i wanted to have "lump of text" from the last sentance as a variable (is that what they're called?) so that i could use it again where ever how would i do it?
 
i have an rss file that im trying to get bits of info out of. i want to get the Shaney out of <user_name><![CDATA[Shaney]]></user_name> and give $name a value of "Shaney" however the best i have been able to do is give it a value of "1" which is no use. this is how i did it:

if ($name = preg_match ("/\<user_name\>\<!\[CDATA\[(.+?)\]\]\>\<\/user_name\>/", $contents)) {

$name = preg_replace ("/\<user_name\>\<!\[CDATA\[/", "", $name);
$name = preg_replace ("/\]\]\>\<\/user_name\>/", "", $name);

print "<p>$name</p>";

}

how do i do it so that $name = Shaney? ive tried using get_meta_tags but that didnt seem to work.

thanks
 
You need to supply an empty array for the third argument to preg_match. The function will add all matches to the array.

$contents = "<user_name><![CDATA[Shaney]]></user_name>";
$expression = "/\<user_name\>\<!\[CDATA\[(.+?)\]\]\>\<\/user_name\>/";
$matches = array();

preg_match ($expression, $contents, $matches);

foreach ($matches as $match)
{
echo $match;
}
 
here, im trying to validate an email address submitted in a form with checkdnsrr. i've copied the same code that works on another site however on this new page im getting the following error with real addresses

Warning: checkdnsrr() [function.checkdnsrr]: Host and type cannot be empty in /home/shane/mail.php on line 30

i dont understand - what are the host and type? heres the code i have


list($mailname, $maildomain) = split("@", $address);
if (checkdnsrr($maildomain, "MX")) {
$problem = FALSE;
} else {
$problem = TRUE;
}

thanks
 

Users who are viewing this thread

Activity
So far there's no one here
Old Thread: Hello . There have been no replies in this thread for 365 days.
Content in this thread may no longer be relevant.
Perhaps it would be better to start a new thread instead.

21 Day Calendar

Mohammad Syfkhan 'I Am Kurdish' Dublin Album Launch
Bello Bar
1 Portobello Harbour, Saint Kevin's, Dublin, Ireland
Mohammad Syfkhan 'I Am Kurdish' Dublin Album Launch
Bello Bar
1 Portobello Harbour, Saint Kevin's, Dublin, Ireland
Gig For Gaza w/ ØXN, Junior Brother, Pretty Happy & Mohammad Syfkhan
Vicar Street
58-59 Thomas St, The Liberties, Dublin 8, Ireland
Bloody Head, Hubert Selby Jr Infants, Creepy Future - Dublin
Anseo
18 Camden Street Lower, Saint Kevin's, Dublin, Ireland

Support thumped.com

Support thumped.com and upgrade your account

Upgrade your account now to disable all ads... If we had any... Which we don't right now.

Upgrade now

Latest threads

Latest Activity

Loading…
Back
Top