close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

mysql to mysqli

Thread began 11/07/2014 8:16 am by Jamie | Last modified 11/07/2014 12:33 pm by Jason Byrnes | 1361 views | 7 replies |

Jamie

mysql to mysqli

Hey Jason

Being a complete dope here and cant remember (or find) how to change this old mysql version

<?php echo(str_replace("http://", "", $row_RSName['ColumnName'])); ?>

to mysqli syntax.....and include https:// to be removed

many thanks

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

in MySQL, the code for a recordset value is:

$row_RSName['ColumnName']



in MySQLi, the corresponding code would be:

$RSName->getColumnVal("ColumnName")




so your code would be:

<?php echo(str_replace("http://", "", $RSName->getColumnVal("ColumnName"))); ?>



to also remove https, create an array of the values to remove:

<?php echo(str_replace(array("http://",https://"), "", $RSName->getColumnVal("ColumnName"))); ?>
Sign in to reply to this post

Jamie

Thank you Jason....that's exactly what I thought but it doesn't work.....

I am using it in an <a href> to put a url in from the databse and to remove the http ot http a if the user has entered it.

If I make it just for http it shows the url and opens the page as it should,...adding in the 2nd parameter stops the link linking to the page

You can see it in action here: http://clients.motley.co.uk/wheels - if you look to the little logos at the bottom left of each page, 2 of them have a link associated with them but aren't working

Sign in to reply to this post

Jason ByrnesWebAssist

it looks like there is a space between the http:// and the address what is the full code you are using for the link.

Sign in to reply to this post

Jamie

It's

<a href="http://
<?php echo(str_replace(array("http://","https://"), "", $SponsorLogos->getColumnVal("SponsorLogosURL"))); ?>
" target="_blank"><?php } ?><img src="images/sponsor-logos/<?php echo($SponsorLogos->getColumnVal("SponsorLogosImage")); ?>" width="" height="30"><?php if ("".($SponsorLogos->getColumnVal("SponsorLogosURL")) ."" != "") { ?></a><?php } ?>
Sign in to reply to this post

Jason ByrnesWebAssist

looks like you have the code on 2 lines.

change:

<a href="http://
<?php echo(str_replace(array("http://","https://"), "", $SponsorLogos->getColumnVal("SponsorLogosURL"))); ?>
" target="_blank">



to:

<a href="http://<?php echo(str_replace(array("http://","https://"), "", $SponsorLogos->getColumnVal("SponsorLogosURL"))); ?>" target="_blank"



so it's all one line

Sign in to reply to this post

Jamie

Hmmmm thought I had ... Currently on a tablet so it's hard to see.

Have just tested it and it works great....as ever thanks for your input

Have a great weekend

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...